Found by GCC14 -Wanalyzer-double-free.
If the os-release file would contain multiple ID or VERSION_ID entries
we would leak the originally parsed one. Fix by seeing whether id or
version is already set and ignore any future entries.
* debuginfod/debuginfod-client.c (add_default_headers): Check
whether id or version is already set before resetting them.
Signed-off-by: Mark Wielaard <mark@klomp.org>
v++;
s[len - 1] = '\0';
}
- if (strcmp (s, "ID") == 0)
+ if (id == NULL && strcmp (s, "ID") == 0)
id = strdup (v);
- if (strcmp (s, "VERSION_ID") == 0)
+ if (version == NULL && strcmp (s, "VERSION_ID") == 0)
version = strdup (v);
}
fclose (f);