diff options
author | Jean-Luc Peurière <jlp@nerim.net> | 2008-03-21 20:00:40 +0300 |
---|---|---|
committer | Jean-Luc Peurière <jlp@nerim.net> | 2008-03-21 20:00:40 +0300 |
commit | 32b5138e6459df5298ca50865dafab4d22a4aeed (patch) | |
tree | 8ba947a61d91fe051e9c3a864f5e0ca61968bca1 /intern/ghost | |
parent | 473ba6ac718bc32b4fc6c6aee4d03673cf62936c (diff) | |
parent | df1ba7da75f9b82f81693d5e0adfec29b2f4a424 (diff) |
update to trunk r14199ndof
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 47bcb76441f..1b0d4448f1d 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -976,7 +976,7 @@ getClipboard(int flag Primary_atom = XInternAtom(m_display, "CLIPBOARD", False); owner = XGetSelectionOwner(m_display, Primary_atom); if (owner == m_window) { - data = (unsigned char*) malloc(strlen(txt_cut_buffer)); + data = (unsigned char*) malloc(strlen(txt_cut_buffer)+1); strcpy((char*)data, txt_cut_buffer); return (GHOST_TUns8*)data; } else if (owner == None) { @@ -986,7 +986,7 @@ getClipboard(int flag Primary_atom = XInternAtom(m_display, "PRIMARY", False); owner = XGetSelectionOwner(m_display, Primary_atom); if (owner == m_window) { - data = (unsigned char*) malloc(strlen(txt_select_buffer)); + data = (unsigned char*) malloc(strlen(txt_select_buffer)+1); strcpy((char*)data, txt_select_buffer); return (GHOST_TUns8*)data; } else if (owner == None) { @@ -1007,10 +1007,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)+1); + strcpy((char*)tmp_data, (char*)data); + XFree(data); + return (GHOST_TUns8*)tmp_data; + } } return NULL; } @@ -1031,13 +1033,13 @@ GHOST_TInt8 *buffer, int flag) const Primary_atom = XInternAtom(m_display, "CLIPBOARD", False); if(txt_cut_buffer) { free((void*)txt_cut_buffer); } - txt_cut_buffer = (char*) malloc(strlen(buffer)); + txt_cut_buffer = (char*) malloc(strlen(buffer)+1); strcpy(txt_cut_buffer, buffer); } else { Primary_atom = XInternAtom(m_display, "PRIMARY", False); if(txt_select_buffer) { free((void*)txt_select_buffer); } - txt_select_buffer = (char*) malloc(strlen(buffer)); + txt_select_buffer = (char*) malloc(strlen(buffer)+1); strcpy(txt_select_buffer, buffer); } |