libxkbcommon-1.0.3/src/xkbcomp/ast-build.c:526: leaked_storage: Variable "file"
going out of scope leaks the storage it points to.
Where we exit the loop early, we don't release the various allocated memory.
Make this patch more obvious my moving the declaration for those into the loop
as well, this way we know that they aren't used outside the loop anywhere.
Found by coverity
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge)
{
IncludeStmt *incl, *first;
- char *file, *map, *stmt, *tmp, *extra_data;
+ char *stmt, *tmp;
char nextop;
incl = first = NULL;
- file = map = NULL;
tmp = str;
stmt = strdup_safe(str);
while (tmp && *tmp)
{
+ char *file = NULL, *map = NULL, *extra_data = NULL;
+
if (!ParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
goto err;
incl = incl->next_incl;
}
- if (!incl)
+ if (!incl) {
+ free(file);
+ free(map);
+ free(extra_data);
break;
+ }
incl->common.type = STMT_INCLUDE;
incl->common.next = NULL;