--- /dev/null
+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