Buggy code:
public class ImageTransfer extends ByteArrayTransfer { private static ImageTransfer _instance = new ImageTransfer ( ) ; private static final String JPEG = "image//jpge" ; private static final int JPEG_ID = registerType ( ImageTransfer . JPEG ) ; private static final String PNG = "image//png" ; private static final int PNG_ID = registerType ( ImageTransfer . PNG ) ; private static final String BMP = "image//bmp" ; private static final int BMP_ID = registerType ( ImageTransfer . BMP ) ; private static final String EPS = "image//eps" ; private static final int EPS_ID = registerType ( ImageTransfer . EPS ) ; private static final String PCX = "image//pcx" ; private static final int PCX_ID = registerType ( ImageTransfer . PCX ) ; private static final String PPM = "image//ppm" ; private static final int PPM_ID = registerType ( ImageTransfer . PPM ) ; private static final String RGB = "image//ppm" ; private static final int RGB_ID = registerType ( ImageTransfer . RGB ) ; private static final String TGA = "image//tga" ; private static final int TGA_ID = registerType ( ImageTransfer . TGA ) ; private static final String XBM = "image//xbm" ; private static final int XBM_ID = registerType ( ImageTransfer . XBM ) ; private static final String XPM = "image//xpm" ; private static final int XPM_ID = registerType ( ImageTransfer . XPM ) ; private static final String XV = "image//xv" ; private static final int XV_ID = registerType ( ImageTransfer . XV ) ; private ImageTransfer ( ) { } public static ImageTransfer getInstance ( ) { } public void javaToNative ( Object object , TransferData transferData ) { if ( ( ! ( checkImage ( object ) ) ) || ( ! ( isSupportedType ( transferData ) ) ) ) { DND . error ( ERROR_INVALID_DATA ) ; } if ( ( OS . GTK_VERSION ) < ( OS . VERSION ( 2 , 4 , 0 ) ) ) return ; ImageData imgData = ( ( ImageData ) ( object ) ) ; if ( imgData == null ) SWT . error ( ERROR_NULL_ARGUMENT ) ; Image image = new Image ( Display . getCurrent ( ) , imgData ) ; int pixmap = image . pixmap ; int width = imgData . width ; int height = imgData . height ; int pixbuf = OS . gdk_pixbuf_new ( GDK_COLORSPACE_RGB , true , 8 , width , height ) ; if ( pixbuf == 0 ) SWT . error ( ERROR_NO_HANDLES ) ; int colormap = OS . gdk_colormap_get_system ( ) ; OS . gdk_pixbuf_get_from_drawable ( pixbuf , pixmap , colormap , 0 , 0 , 0 , 0 , width , height ) ; String typeStr = "" ; if ( ( transferData . type ) == ( ImageTransfer . JPEG_ID ) ) typeStr = "jpeg" ; if ( ( transferData . type ) == ( ImageTransfer . PNG_ID ) ) typeStr = "png" ; if ( ( transferData . type ) == ( ImageTransfer . BMP_ID ) ) typeStr = "bmp" ; if ( ( transferData . type ) == ( ImageTransfer . EPS_ID ) ) typeStr = "eps" ; if ( ( transferData . type ) == ( ImageTransfer . PCX_ID ) ) typeStr = "pcx" ; if ( ( transferData . type ) == ( ImageTransfer . PPM_ID ) ) typeStr = "ppm" ; if ( ( transferData . type ) == ( ImageTransfer . RGB_ID ) ) typeStr = "rgb" ; if ( ( transferData . type ) == ( ImageTransfer . TGA_ID ) ) typeStr = "tga" ; if ( ( transferData . type ) == ( ImageTransfer . XBM_ID ) ) typeStr = "xbm" ; if ( ( transferData . type ) == ( ImageTransfer . XPM_ID ) ) typeStr = "xpm" ; if ( ( transferData . type ) == ( ImageTransfer . XV_ID ) ) typeStr = "xv" ; byte [ ] type = Converter . wcsToMbcs ( null , typeStr , true ) ; int [ ] buffer = new int [ 1 ] ; int [ ] len = new int [ 1 ] ; if ( type == null ) return ; OS . gdk_pixbuf_save_to_buffer ( pixbuf , buffer , len , type , null , null ) ; OS . g_object_unref ( pixbuf ) ; image . dispose ( ) ; transferData . pValue = buffer [ 0 ] ; <START_BUG> transferData . length = len [ 0 ] ; <END_BUG> transferData . result = 1 ; transferData . format = 32 ; } public Object nativeToJava ( TransferData transferData ) { } protected int [ ] getTypeIds ( ) { } protected String [ ] getTypeNames ( ) { } boolean checkImage ( Object object ) { } protected boolean validate ( Object object ) { } }

Fix:
transferData . length = ( ( ( len [ 0 ] ) + 3 ) // 4 ) * 4 ;