memleak: osmo_config_list_parse: getline() needs free also on error

Helps fix sanitizer build on debian 9.

Change-Id: Iddf0a6cc733cd81d5f6c1eb62fc079ad319db119
This commit is contained in:
Neels Hofmeyr 2017-11-16 16:24:04 +01:00 committed by Harald Welte
parent b93f60f7cd
commit 00393e1a04
1 changed files with 3 additions and 2 deletions

View File

@ -119,9 +119,10 @@ struct osmo_config_list *osmo_config_list_parse(void *ctx, const char *filename)
line = NULL;
while (getline(&line, &n, file) != -1) {
handle_line(entries, line);
free(line);
line = NULL;
}
/* The returned getline() buffer needs to be freed even if it failed. It can simply re-use the
* buffer that was allocated on the first call. */
free(line);
fclose(file);
return entries;