From 642997405b48f14550531ee59cdc54a077b744e7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 6 Oct 2017 14:45:05 +0200 Subject: [PATCH] libcollectdclient/network_parse.c: Ensure memory allocated in parse_values() is always freed. Shoutout to scan-build for finding this one! --- src/libcollectdclient/network_parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 4083e1ec..67034116 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -302,8 +302,6 @@ static int parse_values(void *payload, size_t payload_size, state->values = calloc(sizeof(*state->values), state->values_len); state->values_types = calloc(sizeof(*state->values_types), state->values_len); if ((state->values == NULL) || (state->values_types == NULL)) { - free(state->values); - free(state->values_types); return ENOMEM; } @@ -556,6 +554,8 @@ static int network_parse(void *data, size_t data_size, lcc_security_level_t sl, case TYPE_VALUES: { lcc_value_list_t vl = state; if (parse_values(payload, sizeof(payload), &vl)) { + free(vl.values); + free(vl.values_types); DEBUG("lcc_network_parse(): parse_values failed.\n"); return EINVAL; } -- 2.30.2