]> source.dussan.org Git - tigervnc.git/commitdiff
Added Fltk patch from Pierre to fix "checksum for freed object" segfault to contrib...
authorBrian P. Hinz <bphinz@users.sf.net>
Tue, 21 Apr 2015 03:39:13 +0000 (23:39 -0400)
committerBrian P. Hinz <bphinz@users.sf.net>
Tue, 21 Apr 2015 03:39:13 +0000 (23:39 -0400)
contrib/fltk/fltk-1.3.x-osx-clip.patch [new file with mode: 0644]

diff --git a/contrib/fltk/fltk-1.3.x-osx-clip.patch b/contrib/fltk/fltk-1.3.x-osx-clip.patch
new file mode 100644 (file)
index 0000000..9e3fcdc
--- /dev/null
@@ -0,0 +1,77 @@
+diff -up fltk-1.3.3/src/Fl_cocoa.mm.clip fltk-1.3.3/src/Fl_cocoa.mm\r
+--- fltk-1.3.3/src/Fl_cocoa.mm.clip    2014-11-02 22:06:07.000000000 +0100\r
++++ fltk-1.3.3/src/Fl_cocoa.mm 2015-04-20 13:45:03.526688921 +0200\r
+@@ -3061,6 +3061,14 @@ static void clipboard_check(void)\r
+   fl_trigger_clipboard_notify(1);\r
+ }\r
\r
++static void resize_selection_buffer(int len, int clipboard) {\r
++  if (len <= fl_selection_buffer_length[clipboard])\r
++    return;\r
++  delete[] fl_selection_buffer[clipboard];\r
++  fl_selection_buffer[clipboard] = new char[len+100];\r
++  fl_selection_buffer_length[clipboard] = len+100;\r
++}\r
++\r
+ /*\r
+  * create a selection\r
+  * stuff: pointer to selected data\r
+@@ -3069,11 +3077,7 @@ static void clipboard_check(void)\r
+  */\r
+ void Fl::copy(const char *stuff, int len, int clipboard, const char *type) {\r
+   if (!stuff || len<0) return;\r
+-  if (len+1 > fl_selection_buffer_length[clipboard]) {\r
+-    delete[] fl_selection_buffer[clipboard];\r
+-    fl_selection_buffer[clipboard] = new char[len+100];\r
+-    fl_selection_buffer_length[clipboard] = len+100;\r
+-  }\r
++  resize_selection_buffer(len+1, clipboard);\r
+   memcpy(fl_selection_buffer[clipboard], stuff, len);\r
+   fl_selection_buffer[clipboard][len] = 0; // needed for direct paste\r
+   fl_selection_length[clipboard] = len;\r
+@@ -3087,7 +3091,7 @@ void Fl::copy(const char *stuff, int len\r
+   }\r
+ }\r
\r
+-static int get_plain_text_from_clipboard(char **buffer, int previous_length)\r
++static int get_plain_text_from_clipboard(int clipboard)\r
+ {\r
+   NSInteger length = 0;\r
+   NSPasteboard *clip = [NSPasteboard generalPasteboard];\r
+@@ -3109,21 +3113,17 @@ static int get_plain_text_from_clipboard\r
+       len = strlen(aux_c) + 1;\r
+       }\r
+       else len = [data length] + 1;\r
+-      if ( len >= previous_length ) {\r
+-      length = len;\r
+-      delete[] *buffer;\r
+-      *buffer = new char[len];\r
+-      }\r
++      resize_selection_buffer(len, clipboard);\r
+       if (![found isEqualToString:utf8_format]) {\r
+-      strcpy(*buffer, aux_c);\r
+-      free(aux_c);\r
++        strcpy(fl_selection_buffer[clipboard], aux_c);\r
++        free(aux_c);\r
+       }\r
+       else {\r
+-      [data getBytes:*buffer];\r
++        [data getBytes:fl_selection_buffer[clipboard]];\r
+       }\r
+-      (*buffer)[len - 1] = 0;\r
++      fl_selection_buffer[clipboard][len - 1] = 0;\r
+       length = len - 1;\r
+-      convert_crlf(*buffer, len - 1); // turn all \r characters into \n:\r
++      convert_crlf(fl_selection_buffer[clipboard], len - 1); // turn all \r characters into \n:\r
+       Fl::e_clipboard_type = Fl::clipboard_plain_text;\r
+     }\r
+   }    \r
+@@ -3218,7 +3218,7 @@ void Fl::paste(Fl_Widget &receiver, int\r
+   if (clipboard) {\r
+     Fl::e_clipboard_type = "";\r
+    if (strcmp(type, Fl::clipboard_plain_text) == 0) {\r
+-      fl_selection_length[1] = get_plain_text_from_clipboard( &fl_selection_buffer[1],  fl_selection_length[1]);   \r
++      fl_selection_length[1] = get_plain_text_from_clipboard(1);\r
+       }\r
+     else if (strcmp(type, Fl::clipboard_image) == 0) {\r
+       Fl::e_clipboard_data = get_image_from_clipboard( );\r