2018-10-20 17:29:43 +00:00
|
|
|
Avoid leaking pathbuf when path==0 by marking allocation failures as fatal.
|
2020-12-03 19:33:08 +00:00
|
|
|
SPDX-License-Identifier: CC0-1.0
|
2018-10-20 17:29:43 +00:00
|
|
|
--- a/lemon.c
|
|
|
|
+++ b/lemon.c
|
2020-12-03 19:33:08 +00:00
|
|
|
@@ -3538,6 +3548,7 @@ PRIVATE char *pathsearch(char *argv0, char *name, int modemask)
|
2018-10-20 17:29:43 +00:00
|
|
|
if( pathlist==0 ) pathlist = ".:/bin:/usr/bin";
|
|
|
|
pathbuf = (char *) malloc( lemonStrlen(pathlist) + 1 );
|
|
|
|
path = (char *)malloc( lemonStrlen(pathlist)+lemonStrlen(name)+2 );
|
|
|
|
+ MemoryCheck(pathbuf); MemoryCheck(path); /* Fail on allocation failure. */
|
|
|
|
if( (pathbuf != 0) && (path!=0) ){
|
|
|
|
pathbufptr = pathbuf;
|
|
|
|
lemon_strcpy(pathbuf, pathlist);
|