Coverity: completion module resource leaks fixed 01/18201/2
Dhruv Khattar [Tue, 31 May 2016 16:47:47 +0000 (21:47 +0530)]
Change-Id: Ide4a9721f9f3dde2dbc21daed30e61505a80ada5

scilab/modules/completion/sci_gateway/cpp/sci_completion.cpp
scilab/modules/completion/src/c/completion.c
scilab/modules/completion/src/cpp/UnknownMlistFieldsGetter.cpp

index 618089a..8b01fa6 100644 (file)
@@ -93,12 +93,14 @@ types::Function::ReturnValue sci_completion(types::typed_list &in, int _iRetCoun
         if (_iRetCount != 1)
         {
             Scierror(78, _("%s: Wrong number of output argument(s): %d expected."), "completion", 1);
+            FREE(pcSomechars);
             return types::Function::Error;
         }
 
         if (in[1]->isString() == false)
         {
             Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "completion", 2);
+            FREE(pcSomechars);
             return types::Function::Error;
         }
 
@@ -107,6 +109,7 @@ types::Function::ReturnValue sci_completion(types::typed_list &in, int _iRetCoun
         if (pStrDictionary->isScalar() == false)
         {
             Scierror(999, _("%s: Wrong size for input argument #%d: string expected.\n"), "completion", 2);
+            FREE(pcSomechars);
             return types::Function::Error;
         }
 
@@ -139,6 +142,7 @@ types::Function::ReturnValue sci_completion(types::typed_list &in, int _iRetCoun
         {
             Scierror(999, _("%s: Wrong value for input argument: '%s', '%s', '%s', '%s', '%s' or '%s' expected.\n"),
                      "completion", "functions", "commands", "variables", "macros", "graphic_properties", "files");
+            FREE(pcSomechars);
             return types::Function::Error;
         }
     }
index e42173b..d669157 100644 (file)
@@ -92,6 +92,10 @@ char **completion(const char *somechars, int *sizeArrayReturned)
         ListWords = completionOnDictionary(dictionary, sizedictionary, somechars, sizeArrayReturned);
         freePointerDictionary(dictionary, sizedictionary);
     }
+    freePointerDictionary(completionvariables, sizecompletionvariables);
+    freePointerDictionary(completionmacros, sizecompletionmacros);
+    freePointerDictionary(completionhandlegraphicsproperties, sizecompletionhandlegraphicsproperties);
+    freePointerDictionary(completionfunctions, sizecompletionfunctions);
 
     return ListWords;
 }
@@ -281,6 +285,7 @@ char **completionOnVariablesWithoutMacros(const char *somechars, int *sizeArrayR
         ListWords = NULL;
         *sizeArrayReturned = 0;
     }
+    freePointerDictionary(dictionaryVariables, sizedictionaryVariables);
 
     return ListWords;
 }
@@ -373,6 +378,8 @@ char **completionOnHandleGraphicsProperties(const char *somechars, int *sizeArra
     {
         *sizeArrayReturned = 0;
     }
+    freePointerDictionary(HandleGraphicsSetPropertiesDictionary, sizeHandleGraphicsSetPropertiesDictionary);
+    freePointerDictionary(HandleGraphicsGetPropertiesDictionary, sizeHandleGraphicsGetPropertiesDictionary);
     return ListWords;
 }
 /*--------------------------------------------------------------------------*/
index 6cef6cd..9037e1a 100644 (file)
@@ -100,6 +100,7 @@ const char ** UnknownMlistFieldsGetter::getFieldsName(int * mlist, char ** field
             return FieldsManager::getFields(itemAddr, fieldPath, fieldPathLen, fieldsSize);
         }
     }
+    freeArrayOfString(pstData, rc);
 
     return 0;
 }