Coverity: console module resource leaks fixed 02/18202/3
Dhruv Khattar [Tue, 31 May 2016 20:43:46 +0000 (01:43 +0530)]
Change-Id: Ia0123fb4cc3d9d6174006a24cd6532b63653eeab

scilab/modules/console/src/c/cmdLine/autoCompletionCli.c
scilab/modules/console/src/c/dropFiles.c

index eef0154..6df14c9 100644 (file)
@@ -532,7 +532,6 @@ static void TermCompletionOnAll(char *lineBeforeCaret, char *lineAfterCaret, cha
                 {
                     commonAll = getCommonPart(completionDictionaryFields, sizecompletionDictionaryFields);
                     displayCompletionDictionary(completionDictionaryFields, sizecompletionDictionaryFields, (char *)_("Scilab Fields"));
-                    freeArrayOfString(completionDictionaryFields, sizecompletionDictionaryFields);
                 }
                 else
                 {
@@ -562,8 +561,8 @@ static void TermCompletionOnAll(char *lineBeforeCaret, char *lineAfterCaret, cha
                         {
                             commonAll = getCommonPart(commonsDictionary, sizecommonsDictionary);
                         }
-                        freeArrayOfString(commonsDictionary, sizecommonsDictionary);
                     }
+                    freeArrayOfString(commonsDictionary, sizecommonsDictionary);
 
                     displayCompletionDictionary(completionDictionaryFunctions, sizecompletionDictionaryFunctions, (char *)_("Scilab Function"));
                     displayCompletionDictionary(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords, (char *)_("Scilab Command"));
@@ -571,11 +570,6 @@ static void TermCompletionOnAll(char *lineBeforeCaret, char *lineAfterCaret, cha
                     displayCompletionDictionary(completionDictionaryVariables, sizecompletionDictionaryVariables, (char *)_("Scilab Variable"));
                     displayCompletionDictionary(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties,
                                                 (char *)_("Graphics handle field"));
-                    freeArrayOfString(completionDictionaryFunctions, sizecompletionDictionaryFunctions);
-                    freeArrayOfString(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords);
-                    freeArrayOfString(completionDictionaryMacros, sizecompletionDictionaryMacros);
-                    freeArrayOfString(completionDictionaryVariables, sizecompletionDictionaryVariables);
-                    freeArrayOfString(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties);
                 }
 
                 printf("\n");
@@ -606,6 +600,12 @@ static void TermCompletionOnAll(char *lineBeforeCaret, char *lineAfterCaret, cha
                 }
             }
         }
+        freeArrayOfString(completionDictionaryFields, sizecompletionDictionaryFields);
+        freeArrayOfString(completionDictionaryFunctions, sizecompletionDictionaryFunctions);
+        freeArrayOfString(completionDictionaryCommandWords, sizecompletionDictionaryCommandWords);
+        freeArrayOfString(completionDictionaryMacros, sizecompletionDictionaryMacros);
+        freeArrayOfString(completionDictionaryVariables, sizecompletionDictionaryVariables);
+        freeArrayOfString(completionDictionaryHandleGraphicsProperties, sizecompletionDictionaryHandleGraphicsProperties);
     }
 }
 
index deb37f8..2d506b8 100644 (file)
@@ -99,8 +99,8 @@ BOOL LaunchFilebyExtension(char *File)
 
     if (FileExtension)
     {
-        FREE(CommandLine);
-        CommandLine = NULL;
+        FREE(FileExtension);
+        FileExtension = NULL;
     }
 
     return bOK;