diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2024-05-02 21:24:20 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2024-05-02 21:37:17 +0100 |
commit | 94f7d92631d87f968ffd559b2302aa1eb7cf840c (patch) | |
tree | f55225a1eb101525790484827e7cb296817f08ff /src/builtins.c | |
parent | c4ee664d0b2f4e118106fdd49eb50d9fb3eaeee3 (diff) |
Initialise getdelim buf pointers to NULL
getdelim can either be passed NULL or a malloc allocated buffer. I am
not sure why on glibc on linux this doesn't outright crash, but it does
crash on my ARM phone.
By initialising to NULL, getdelim correctly allocates a buffer for the
data rather than reallocating a string literal.
Diffstat (limited to 'src/builtins.c')
-rw-r--r-- | src/builtins.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/builtins.c b/src/builtins.c index caf18c2..d6049f3 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -540,7 +540,7 @@ void stemfread(value_t *v) { eval_error("EMPTY STACK"); return; } - char *val = ""; + char *val = NULL; size_t len = 0; FILE *fp = fopen(v1->str_word->value, "rb"); if (!fp) { @@ -1341,7 +1341,7 @@ void include(value_t *v) { eval_error("EMPTY STACK"); return; } - char *val = ""; + char *val = NULL; size_t len = 0; string_t *strval = init_string("/usr/local/share/stem/stemlib/"); string_concat(strval, v1->str_word); |