From b4a3ce9d0878b69d25afc0028e762084c25ac8c6 Mon Sep 17 00:00:00 2001 From: Fabien Costantini Date: Tue, 27 Jan 2009 13:38:23 +0000 Subject: STR#2133 fix: erroneously releasing flavorType would cause a crash when pasting twice in an Fl_Input object. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6646 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_mac.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index dc35f3f93..f17e79cb7 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -2597,7 +2597,7 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { if (err!=noErr) continue; err = PasteboardCopyItemFlavors(myPasteboard, itemID, &flavorTypeArray); if (err!=noErr) { - if (flavorTypeArray) {CFRelease (flavorTypeArray); flavorTypeArray = NULL;} + if (flavorTypeArray) {CFRelease(flavorTypeArray); flavorTypeArray = NULL;} continue; } CFIndex flavorCount = CFArrayGetCount(flavorTypeArray); @@ -2609,20 +2609,18 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { if(err != noErr) continue; encoding = encodings[j]; found = true; - if (flavorType) CFRelease(flavorType); break; } - if (flavorType) {CFRelease(flavorType); flavorType = NULL;} } if(found) break; } - if (flavorTypeArray) {CFRelease (flavorTypeArray); flavorTypeArray = NULL;} + if (flavorTypeArray) {CFRelease(flavorTypeArray); flavorTypeArray = NULL;} if (found) break; } if(found) { CFIndex len = CFDataGetLength(flavorData); CFStringRef mycfs = CFStringCreateWithBytes(NULL, CFDataGetBytePtr(flavorData), len, encoding, false); - CFRelease (flavorData); + CFRelease(flavorData); len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(mycfs), kCFStringEncodingUTF8) + 1; if ( len >= fl_selection_buffer_length[1] ) { fl_selection_buffer_length[1] = len; @@ -2630,7 +2628,7 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { fl_selection_buffer[1] = new char[len]; } CFStringGetCString(mycfs, fl_selection_buffer[1], len, kCFStringEncodingUTF8); - CFRelease (mycfs); + CFRelease(mycfs); len = strlen(fl_selection_buffer[1]); fl_selection_length[1] = len; convert_crlf(fl_selection_buffer[1],len); // turn all \r characters into \n: -- cgit v1.2.3