AddressSanitizer: fix some issues at first usage 33/20733/2
Clément DAVID [Fri, 18 Jan 2019 14:24:56 +0000 (15:24 +0100)]
 * Console completion is almost always use on debug
 * UI does not display without the Uimenu fix

Change-Id: Idf6d3406ea0648db3e1595a112dda35fb79a15e3

scilab/modules/completion/src/c/completeLine.c
scilab/modules/gui/src/cpp/GetUimenuLabel.cpp

index ff38848..d969f87 100644 (file)
@@ -69,6 +69,13 @@ static int findMatchingPrefixSuffix(const char* string, const char* find, BOOL s
         }
         // Cut tmpfind at this position
         movingPointerOnFindCopy[0] = '\0';
+        // if a prefix is already found and could not grow anymore, return what we found
+        if (stringLength < strlen(pointerOnFindCopy))
+        {
+            FREE(pointerOnFindCopy);
+            pointerOnFindCopy = NULL;
+            return (int)(pointerOnString - string);
+        }
         //Check if the cutted tmpfind match with the suffix of string that has adequat length
         pointerOnString = (char*)(string + stringLength - 1 - strlen(pointerOnFindCopy));
         if ( !strnicmp(pointerOnFindCopy, pointerOnString, strlen(pointerOnFindCopy)) )
index d03e8cb..6a24345 100644 (file)
@@ -35,7 +35,7 @@ void* GetUimenuLabel(void* _pvCtx, int iOobjUID)
     else
     {
         status = sciReturnString(label);
-        free(label);
+        delete[] label;
         return status;
     }
 }