diff options
author | Vincent Sanders <vince@kyllikki.org> | 2016-08-06 01:20:37 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2016-08-06 01:20:37 +0100 |
commit | 62b76bf31aa79db6b16e9c6601b89f821bf970f1 (patch) | |
tree | ba632995a0ed4d1bbade41ed8efb65a1591a0131 /utils/nsoption.c | |
parent | b2a78c5c6e28957aa1f3e22dc23516cd8b251caf (diff) | |
download | netsurf-62b76bf31aa79db6b16e9c6601b89f821bf970f1.tar.gz netsurf-62b76bf31aa79db6b16e9c6601b89f821bf970f1.tar.bz2 |
improve option test coverage futher
Diffstat (limited to 'utils/nsoption.c')
-rw-r--r-- | utils/nsoption.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/nsoption.c b/utils/nsoption.c index e4354bf3f..6754d2131 100644 --- a/utils/nsoption.c +++ b/utils/nsoption.c @@ -822,14 +822,22 @@ nsoption_snoptionf(char *string, int fmtc = 0; /* current index into format string */ struct nsoption_s *option; - if (option_idx >= NSOPTION_LISTEND) { + if (fmt == NULL) { return -1; } - option = &nsoptions[option_idx]; /* assume the global table */ - if (option == NULL || option->key == NULL) + if ((option_idx < 0) || (option_idx >= NSOPTION_LISTEND)) { + return -1; + } + + if (nsoptions == NULL) { return -1; + } + option = &nsoptions[option_idx]; /* assume the global table */ + if (option == NULL || option->key == NULL) { + return -1; + } while ((slen < size) && (fmt[fmtc] != 0)) { if (fmt[fmtc] == '%') { |