summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 255a2d9)
raw | patch | inline | side by side (parent: 255a2d9)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 21 Aug 2014 03:15:40 +0000 (20:15 -0700) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 21 Aug 2014 03:15:40 +0000 (20:15 -0700) |
Correctly access all information indexed by data_names_len and make sure not
to access array members if the array is NULL.
to access array members if the array is NULL.
src/core/timeseries.c | patch | blob | history |
diff --git a/src/core/timeseries.c b/src/core/timeseries.c
index 48da7f8dab9e47a4ad12b77f8df65bf39fc117bc..06c321c3f253198e47b57303bbcbe7b30df4d6ad 100644 (file)
--- a/src/core/timeseries.c
+++ b/src/core/timeseries.c
if (! ts)
return;
- if (ts->data)
+ if (ts->data) {
+ for (i = 0; i < ts->data_names_len; ++i) {
+ if (ts->data[i])
+ free(ts->data[i]);
+ ts->data[i] = NULL;
+ }
free(ts->data);
+ }
ts->data = NULL;
ts->data_len = 0;
- for (i = 0; i < ts->data_names_len; ++i) {
- if (ts->data_names[i])
- free(ts->data_names[i]);
- ts->data_names[i] = NULL;
- }
- if (ts->data_names)
+ if (ts->data_names) {
+ for (i = 0; i < ts->data_names_len; ++i) {
+ if (ts->data_names[i])
+ free(ts->data_names[i]);
+ ts->data_names[i] = NULL;
+ }
free(ts->data_names);
+ }
ts->data_names = NULL;
ts->data_names_len = 0;
} /* sdb_timeseries_destroy */