Buggy code:
dashes [ i ] = dash ; dashes [ ( i + ( data . lineDashes . length ) ) ] = dash ; } } } } if ( dashes != null ) { Gdip . Pen_SetDashPattern ( pen , dashes , dashes . length ) ; Gdip . Pen_SetDashStyle ( pen , DashStyleCustom ) ; } else { Gdip . Pen_SetDashStyle ( pen , dashStyle ) ; } } if ( ( state & ( GC . LINE_JOIN ) ) != 0 ) { int joinStyle = 0 ; switch ( data . lineJoin ) { case SWT . JOIN_MITER : joinStyle = Gdip . LineJoinMiter ; break ; case SWT . JOIN_BEVEL : joinStyle = Gdip . LineJoinBevel ; break ; case SWT . JOIN_ROUND : joinStyle = Gdip . LineJoinRound ; break ; } Gdip . Pen_SetLineJoin ( pen , joinStyle ) ; } if ( ( state & ( GC . LINE_CAP ) ) != 0 ) { int dashCap = Gdip . DashCapFlat ; int capStyle = 0 ; switch ( data . lineCap ) { case SWT . CAP_FLAT : capStyle = Gdip . LineCapFlat ; break ; case SWT . CAP_ROUND : capStyle = Gdip . LineCapRound ; dashCap = Gdip . DashCapRound ; break ; case SWT . CAP_SQUARE : capStyle = Gdip . LineCapSquare ; break ; } Gdip . Pen_SetLineCap ( pen , capStyle , capStyle , dashCap ) ; } if ( ( state & ( GC . BACKGROUND ) ) != 0 ) { if ( ( data . gdipBgBrush ) != 0 ) Gdip . SolidBrush_delete ( data . gdipBgBrush ) ; data . gdipBgBrush = 0 ; Pattern pattern = data . backgroundPattern ; if ( pattern != null ) { data . gdipBrush = pattern . handle ; } else { int background = data . background ; int rgb = ( ( ( background > > 16 ) & 255 ) | ( background & 65280 ) ) | ( ( background & 255 ) << 16 ) ; int color = Gdip . Color_new ( ( ( ( data . alpha ) << 24 ) | rgb ) ) ; if ( color == 0 ) SWT . error ( ERROR_NO_HANDLES ) ; int brush = Gdip . SolidBrush_new ( color ) ; if ( brush == 0 ) SWT . error ( ERROR_NO_HANDLES ) ; Gdip . Color_delete ( color ) ; data . gdipBrush = data . gdipBgBrush = brush ; } } if ( ( state & ( GC . FONT ) ) != 0 ) { OS . SelectObject ( handle , data . hFont ) ; int font = GC . createGdipFont ( handle , data . hFont ) ; if ( ( data . gdipFont ) != 0 ) Gdip . Font_delete ( data . gdipFont ) ; data . gdipFont = font ; } return ; } if ( ( state & ( ( ( ( ( GC . FOREGROUND ) | ( GC . LINE_CAP ) ) | ( GC . LINE_JOIN ) ) | ( GC . LINE_STYLE ) ) | ( GC . LINE_WIDTH ) ) ) != 0 ) { int color = data . foreground ; int width = data . lineWidth ; int [ ] dashes = null ; int lineStyle = OS . PS_SOLID ; switch ( data . lineStyle ) { case SWT . LINE_SOLID : break ; case SWT . LINE_DASH : lineStyle = OS . PS_DASH ; break ; case SWT . LINE_DOT : lineStyle = OS . PS_DOT ; break ; case SWT . LINE_DASHDOT : lineStyle = OS . PS_DASHDOT ; break ; case SWT . LINE_DASHDOTDOT : lineStyle = OS . PS_DASHDOTDOT ; break ; case SWT . LINE_CUSTOM : { <START_BUG> if ( ( data . lineDashes ) == null ) { <END_BUG> lineStyle = OS . PS_USERSTYLE ; dashes = data . lineDashes ; } break ; } } if ( ( state & ( GC . LINE_STYLE ) ) != 0 ) { OS . SetBkMode ( handle , ( ( data . lineStyle ) == ( SWT . LINE_SOLID ) ? OS . OPAQUE : OS . TRANSPARENT ) ) ; } int joinStyle = 0 ; switch ( data . lineJoin ) { case SWT . JOIN_MITER : joinStyle = OS . PS_JOIN_MITER ; break ; case SWT . JOIN_ROUND : joinStyle = OS . PS_JOIN_ROUND ; break ; case SWT . JOIN_BEVEL : joinStyle = OS . PS_JOIN_BEVEL ; break ; } int capStyle = 0 ; switch ( data . lineCap ) { case SWT . CAP_ROUND : capStyle = OS . PS_ENDCAP_ROUND ; break ; case SWT . CAP_FLAT : capStyle = OS . PS_ENDCAP_FLAT ; break ; case SWT . CAP_SQUARE : capStyle = OS . PS_ENDCAP_SQUARE ; break ; } int style = ( lineStyle | joinStyle ) | capStyle ; int newPen ; if ( ( ( OS . IsWinCE ) || ( ( width == 0 ) && ( lineStyle != ( OS . PS_USERSTYLE ) ) ) ) || ( style == 0 ) ) { newPen = OS . CreatePen ( ( style & ( OS . PS_STYLE_MASK ) ) , width , color ) ; } else { LOGBRUSH logBrush = new LOGBRUSH ( ) ; logBrush . lbStyle = OS . BS_SOLID ; logBrush . lbColor = color ; newPen = OS . ExtCreatePen ( ( style | ( OS . PS_GEOMETRIC ) ) , Math . max ( 1 , width ) , logBrush , ( dashes != null ? dashes . length : 0 ) , dashes ) ; } OS . SelectObject ( handle , newPen ) ; data . state |= GC . PEN ;

Fix:
if ( ( data . lineDashes ) != null ) {