Skip to content

Commit 507ee88

Browse files
committed
Fix free-before-use bugs.
Signed-off-by: Ross Golder <ross@golder.org>
1 parent 7611f23 commit 507ee88

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

plugins/in_node_exporter_metrics/ne_utils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ int ne_utils_file_read_uint64(struct flb_ne *ctx,
132132
flb_sds_destroy(p);
133133
return -1;
134134
}
135-
flb_sds_destroy(p);
136135

137136
bytes = read(fd, &tmp, sizeof(tmp));
138137
if (bytes == -1) {
@@ -143,9 +142,11 @@ int ne_utils_file_read_uint64(struct flb_ne *ctx,
143142
flb_errno();
144143
}
145144
close(fd);
145+
flb_sds_destroy(p);
146146
return -1;
147147
}
148148
close(fd);
149+
flb_sds_destroy(p);
149150

150151
ret = ne_utils_str_to_uint64(tmp, &val);
151152
if (ret == -1) {
@@ -277,7 +278,6 @@ int ne_utils_file_read_sds(struct flb_ne *ctx,
277278
flb_sds_destroy(p);
278279
return -1;
279280
}
280-
flb_sds_destroy(p);
281281

282282
bytes = read(fd, &tmp, sizeof(tmp));
283283
if (bytes == -1) {
@@ -288,9 +288,11 @@ int ne_utils_file_read_sds(struct flb_ne *ctx,
288288
flb_errno();
289289
}
290290
close(fd);
291+
flb_sds_destroy(p);
291292
return -1;
292293
}
293294
close(fd);
295+
flb_sds_destroy(p);
294296

295297
for (i = bytes-1; i > 0; i--) {
296298
if (tmp[i] != '\n' && tmp[i] != '\r') {

0 commit comments

Comments
 (0)