Added null check to prevent crashing on paste.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 18 Mar 2008 16:12:43 +0000 (16:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 18 Mar 2008 16:12:43 +0000 (16:12 +0000)
Should look into why XGetWindowProperty isnt working also.

intern/ghost/intern/GHOST_SystemX11.cpp

index 55881b1f007f16138a531b2e14c70d8bddad21f8..0329241045ffbace85b13b2e2f0c8ff1e1150d65 100644 (file)
@@ -990,10 +990,12 @@ getClipboard(int flag
                XNextEvent(m_display, &xevent);
                if(xevent.type == SelectionNotify) {
                        if(XGetWindowProperty(m_display, m_window, xevent.xselection.property, 0L, 4096L, False, AnyPropertyType, &rtype, &bits, &len, &bytes, &data) == Success) {
-                               tmp_data = (unsigned char*) malloc(strlen((char*)data));
-                               strcpy((char*)tmp_data, (char*)data);
-                               XFree(data);
-                               return (GHOST_TUns8*)tmp_data;
+                               if (data) {
+                                       tmp_data = (unsigned char*) malloc(strlen((char*)data));
+                                       strcpy((char*)tmp_data, (char*)data);
+                                       XFree(data);
+                                       return (GHOST_TUns8*)tmp_data;
+                               }
                        }
                        return NULL;
                }