diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-04-07 12:34:39 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-04-07 12:34:39 +0200 |
commit | 397c902d7eb8c250bbc480f826cc873e287f94c7 (patch) | |
tree | f50cf72f86211e9adb53adf2b5395d4c09b23f4f /src/lexer.c | |
parent | 6f4faecf91e08d7684030b3b28cef706e5296b21 (diff) |
Fix a potential NULL pointer dereference.
Diffstat (limited to 'src/lexer.c')
-rw-r--r-- | src/lexer.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lexer.c b/src/lexer.c index 5863ef6..a3d5b61 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -85,8 +85,11 @@ char *vstr_strdup(vstr_t *vstr) return str; } -char *vstr_to_cstr(vstr_t *vstr) +const char *vstr_to_cstr(vstr_t *vstr) { + if (!vstr->size) + return NULL; + vstr->data[vstr->size] = '\0'; return vstr->data; } |