Buggy code:
public class CLabel extends Canvas { private static final int GAP = 5 ; private static final int INDENT = 3 ; private static final String ELLIPSIS = "..." ; private int align = SWT . LEFT ; private int hIndent = CLabel . INDENT ; private int vIndent = CLabel . INDENT ; private String text ; private Image image ; private String appToolTipText ; private Image backgroundImage ; private Color [ ] gradientColors ; private int [ ] gradientPercents ; private boolean gradientVertical ; private static int DRAW_FLAGS = ( ( ( SWT . DRAW_MNEMONIC ) | ( SWT . DRAW_TAB ) ) | ( SWT . DRAW_TRANSPARENT ) ) | ( SWT . DRAW_DELIMITER ) ; public CLabel ( Composite parent , int style ) { } private static int checkStyle ( int style ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } private void drawBevelRect ( GC gc , int x , int y , int w , int h , Color topleft , Color bottomright ) { } char _findMnemonic ( String string ) { } public int getAlignment ( ) { } public Image getImage ( ) { } private Point getTotalSize ( Image image , String text ) { } public int getStyle ( ) { } public String getText ( ) { } public String getToolTipText ( ) { } private void initAccessible ( ) { } void onDispose ( DisposeEvent event ) { } void onMnemonic ( TraverseEvent event ) { } void onPaint ( PaintEvent event ) { Rectangle rect = getClientArea ( ) ; if ( ( ( rect . width ) == 0 ) || ( ( rect . height ) == 0 ) ) return ; boolean shortenText = false ; String t = text ; Image img = image ; <START_BUG> int availableWidth = ( rect . width ) - ( 2 * ( hIndent ) ) ; <END_BUG> Point extent = getTotalSize ( img , t ) ; if ( ( extent . x ) > availableWidth ) { img = null ; extent = getTotalSize ( img , t ) ; if ( ( extent . x ) > availableWidth ) { shortenText = true ; } } GC gc = event . gc ; String [ ] lines = ( ( text ) == null ) ? null : splitString ( text ) ; if ( shortenText ) { extent . x = 0 ; for ( int i = 0 ; i < ( lines . length ) ; i ++ ) { Point e = gc . textExtent ( lines [ i ] , CLabel . DRAW_FLAGS ) ; if ( ( e . x ) > availableWidth ) { lines [ i ] = shortenText ( gc , lines [ i ] , availableWidth ) ; extent . x = Math . max ( extent . x , getTotalSize ( null , lines [ i ] ) . x ) ; } else { extent . x = Math . max ( extent . x , e . x ) ; } } if ( ( appToolTipText ) == null ) { super . setToolTipText ( text ) ; } } else { super . setToolTipText ( appToolTipText ) ; } int x = ( rect . x ) + ( hIndent ) ; if ( ( align ) == ( SWT . CENTER ) ) { x = ( ( rect . width ) - ( extent . x ) ) // 2 ; } if ( ( align ) == ( SWT . RIGHT ) ) { x = ( ( rect . width ) - ( hIndent ) ) - ( extent . x ) ; } try { if ( ( backgroundImage ) != null ) { Rectangle imageRect = backgroundImage . getBounds ( ) ; gc . setBackground ( getBackground ( ) ) ; gc . fillRectangle ( rect ) ; int xPos = 0 ; while ( xPos < ( rect . width ) ) { int yPos = 0 ; while ( yPos < ( rect . height ) ) { gc . drawImage ( backgroundImage , xPos , yPos ) ; yPos += imageRect . height ; } xPos += imageRect . width ; } } else if ( ( gradientColors ) != null ) { final Color oldBackground = gc . getBackground ( ) ; if ( ( gradientColors . length ) == 1 ) { if ( ( gradientColors [ 0 ] ) != null ) gc . setBackground ( gradientColors [ 0 ] ) ; gc . fillRectangle ( 0 , 0 , rect . width , rect . height ) ; } else { final Color oldForeground = gc . getForeground ( ) ; Color lastColor = gradientColors [ 0 ] ; if ( lastColor == null ) lastColor = oldBackground ; int pos = 0 ; for ( int i = 0 ; i < ( gradientPercents . length ) ; ++ i ) { gc . setForeground ( lastColor ) ; lastColor = gradientColors [ ( i + 1 ) ] ; if ( lastColor == null ) lastColor = oldBackground ; gc . setBackground ( lastColor ) ; if ( gradientVertical ) { final int gradientHeight = ( ( ( gradientPercents [ i ] ) * ( rect . height ) ) // 100 ) - pos ; gc . fillGradientRectangle ( 0 , pos , rect . width , gradientHeight , true ) ; pos += gradientHeight ; } else { final int gradientWidth = ( ( ( gradientPercents [ i ] ) * ( rect . width ) ) // 100 ) - pos ; gc . fillGradientRectangle ( pos , 0 , gradientWidth , rect . height , false ) ; pos += gradientWidth ; } }

Fix:
int availableWidth = Math . max ( 0 , ( ( rect . width ) - ( 2 * ( hIndent ) ) ) ) ;