From 0836f376e5aa1991b4339b914f398411c9f7ec5a Mon Sep 17 00:00:00 2001 From: Fabien Costantini Date: Sat, 17 Jan 2009 09:18:46 +0000 Subject: [PATCH] STR#2121: fixed a potential memory leak on flavorType, made local stack variables declaration zero initialized when necessary, those not zero initialized are now declared when used. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6636 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_mac.cxx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 7c4689250..dc35f3f93 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -2580,9 +2580,9 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { fl_selection_length[1] = 0; #ifdef USE_PASTEBOARD OSStatus err = noErr; - Boolean found=false; - CFDataRef flavorData; - CFStringEncoding encoding=0; + Boolean found = false; + CFDataRef flavorData = NULL; + CFStringEncoding encoding = 0; allocatePasteboard(); PasteboardSynchronize(myPasteboard); @@ -2590,9 +2590,8 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { err = PasteboardGetItemCount(myPasteboard, &nFlavor); if (err==noErr) { for (i=1; i<=nFlavor; i++) { - PasteboardItemID itemID; - CFArrayRef flavorTypeArray; - CFIndex flavorCount; + PasteboardItemID itemID = 0; + CFArrayRef flavorTypeArray = NULL; found = false; err = PasteboardGetItemIdentifier(myPasteboard, i, &itemID); if (err!=noErr) continue; @@ -2601,18 +2600,19 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { if (flavorTypeArray) {CFRelease (flavorTypeArray); flavorTypeArray = NULL;} continue; } - flavorCount = CFArrayGetCount(flavorTypeArray); + CFIndex flavorCount = CFArrayGetCount(flavorTypeArray); for (j = 0; j < handledFlavorsCount; j++) { for (CFIndex flavorIndex=0; flavorIndex= fl_selection_buffer_length[1] ) {