[Git][cmucl/cmucl][issue-306-lisp.c] check_ptr takes const ptr and add more uses of it
Raymond Toy pushed to branch issue-306-lisp.c at cmucl / cmucl Commits: 7fe88dcd by Raymond Toy at 2024-04-28T12:40:22-07:00 check_ptr takes const ptr and add more uses of it `check_ptr` takes a `const void* ptr` since it doesn't modify anything. Add more uses of `check_ptr` to verify that `strdup` and `malloc` returned a non-NULL pointer. - - - - - 1 changed file: - src/lisp/lisp.c Changes: ===================================== src/lisp/lisp.c ===================================== @@ -45,7 +45,7 @@ static void -check_ptr(void* ptr, const char* msg) +check_ptr(const void* ptr, const char* msg) { if (ptr == NULL) { perror(msg); @@ -276,6 +276,8 @@ default_cmucllib(const char *argv0arg) /* Create the colon separated list of directories */ defpath = malloc(total_len + 1); + check_ptr(defpath, "No space for cmucllib path"); + *defpath = '\0'; ptr = cmucllib_search_list; @@ -395,6 +397,8 @@ prepend_core_path(const char *lib, const char *corefile) } result = malloc(strlen(path) + strlen(lib) + 2); + check_ptr(result, "No space final core path"); + strcpy(result, path); strcat(result, ":"); strcat(result, lib); @@ -748,12 +752,14 @@ main(int argc, const char *argv[], const char *envp[]) */ if (lib != NULL) { cmucllib = strdup(lib); + check_ptr(cmucllib, "No space for strdup(lib)"); } else { char *libvar; libvar = getenv("CMUCLLIB"); if (libvar != NULL) { cmucllib = strdup(libvar); + check_ptr(cmucllib, "No space for strdup(libvar)"); } else { /* * The following doesn't make sense for executables. They @@ -784,7 +790,6 @@ main(int argc, const char *argv[], const char *envp[]) } } - /* Only look for a core file if we're not using a built-in image. */ if (builtin_image_flag == 0) { /* View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7fe88dcd1cf24150a385c128... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7fe88dcd1cf24150a385c128... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)