summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util-strings.h2
-rw-r--r--test/test-utils.c4
-rw-r--r--tools/shared.c4
3 files changed, 6 insertions, 4 deletions
diff --git a/src/util-strings.h b/src/util-strings.h
index bc263f6c..ee463dc6 100644
--- a/src/util-strings.h
+++ b/src/util-strings.h
@@ -419,7 +419,7 @@ strstrip(const char *input, const char *what)
last = str;
- for (char *c = str; *c != '\0'; c++) {
+ for (char *c = str; c && *c != '\0'; c++) {
if (!strchr(what, *c))
last = c + 1;
}
diff --git a/test/test-utils.c b/test/test-utils.c
index ee9cc606..d1b7345a 100644
--- a/test/test-utils.c
+++ b/test/test-utils.c
@@ -1218,8 +1218,10 @@ START_TEST(double_array_from_string_test)
&len);
ck_assert_int_eq(len, t->len);
- for (size_t idx = 0; idx < len; idx++)
+ for (size_t idx = 0; idx < len; idx++) {
+ ck_assert_ptr_nonnull(array);
ck_assert_double_eq(array[idx], t->array[idx]);
+ }
free(array);
t++;
diff --git a/tools/shared.c b/tools/shared.c
index 58a428f8..06f027c1 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -360,7 +360,7 @@ tools_parse_option(int option,
size_t npoints = 0;
double *range = double_array_from_string(optarg, ":", &npoints);
- if (npoints != 2 || range[0] < 0.0 || range[1] > 1.0 || range[0] >= range[1]) {
+ if (npoints != 2 || !range || range[0] < 0.0 || range[1] > 1.0 || range[0] >= range[1]) {
free(range);
fprintf(stderr, "Invalid pressure range, must be in format \"min:max\"\n");
return 1;
@@ -376,7 +376,7 @@ tools_parse_option(int option,
size_t npoints = 0;
double *matrix = double_array_from_string(optarg, " ", &npoints);
- if (npoints != 6) {
+ if (!matrix || npoints != 6) {
free(matrix);
fprintf(stderr, "Invalid calibration matrix, must be 6 space-separated values\n");
return 1;