diff options
| author | Frank Busse <bb0xfb@gmail.com> | 2020-11-26 19:49:59 +0000 |
|---|---|---|
| committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2021-04-30 22:21:54 +0100 |
| commit | 43321064287cca6af7c15f173bbcefc351960cc0 (patch) | |
| tree | 93ac6cf5ce308190700c9422260a08bca07fabba /runtime/POSIX/klee_init_env.c | |
| parent | 636f020de2b3d0711166f337d0ae6f8f822449b8 (diff) | |
| download | klee-43321064287cca6af7c15f173bbcefc351960cc0.tar.gz | |
posix runtime: add malloc checks
Diffstat (limited to 'runtime/POSIX/klee_init_env.c')
| -rw-r--r-- | runtime/POSIX/klee_init_env.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/runtime/POSIX/klee_init_env.c b/runtime/POSIX/klee_init_env.c index f45ddf3c..aaee4c4e 100644 --- a/runtime/POSIX/klee_init_env.c +++ b/runtime/POSIX/klee_init_env.c @@ -16,9 +16,6 @@ #include <stdlib.h> #include <string.h> #include <assert.h> -#include <errno.h> -#include <sys/syscall.h> -#include <unistd.h> static void __emit_error(const char *msg) { klee_report_error(__FILE__, __LINE__, msg, "user.err"); @@ -62,12 +59,14 @@ static int __streq(const char *a, const char *b) { static char *__get_sym_str(int numChars, char *name) { int i; char *s = malloc(numChars+1); + if (!s) + __emit_error("out of memory in klee_init_env"); klee_mark_global(s); klee_make_symbolic(s, numChars+1, name); for (i=0; i<numChars; i++) klee_posix_prefer_cex(s, __isprint(s[i])); - + s[numChars] = '\0'; return s; } @@ -223,6 +222,8 @@ usage: (klee_init_env) [options] [program arguments]\n\ } final_argv = (char **)malloc((new_argc + 1) * sizeof(*final_argv)); + if (!final_argv) + __emit_error("out of memory in klee_init_env"); klee_mark_global(final_argv); memcpy(final_argv, new_argv, new_argc * sizeof(*final_argv)); final_argv[new_argc] = 0; |
