diff options
author | Thomas White <taw@physics.org> | 2017-10-26 23:22:59 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-10-26 23:22:59 +0200 |
commit | 34fc6a05736db1121a792b3aeb7c1c45deff510b (patch) | |
tree | 4bba10606a557784ed51c8c38af9ccc80dc0b44a /src/sc_parse.c | |
parent | 8f73f9916207bc9fc681e6cf4fef5673840e6568 (diff) |
Avoid some NULL dereferences
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r-- | src/sc_parse.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sc_parse.c b/src/sc_parse.c index 4838bc6..3853800 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -786,10 +786,13 @@ SCBlock *sc_block_split(SCBlock *bl, size_t pos) /* Second block */ n->name = s_strdup(bl->name); n->options = s_strdup(bl->options); - n->contents = strdup(bl->contents+pos); - - /* Truncate the first block */ - bl->contents[pos] = '\0'; + if ( bl->contents != NULL ) { + n->contents = strdup(bl->contents+pos); + /* Truncate the first block */ + bl->contents[pos] = '\0'; + } else { + n->contents = NULL; + } n->next = bl->next; bl->next = n; |