If SquashFS magic number is invalid, there's a memory leak.
Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
/* Make sure it has a valid SquashFS magic number*/
if (get_unaligned_le32(&sblk->s_magic) != SQFS_MAGIC_NUMBER) {
printf("Bad magic number for SquashFS image.\n");
- ctxt.cur_dev = NULL;
- return -EINVAL;
+ ret = -EINVAL;
+ goto error;
}
ctxt.sblk = sblk;
ret = sqfs_decompressor_init(&ctxt);
if (ret) {
- ctxt.cur_dev = NULL;
- free(ctxt.sblk);
- return -EINVAL;
+ ret = -EINVAL;
+ goto error;
}
return 0;
+error:
+ ctxt.cur_dev = NULL;
+ free(ctxt.sblk);
+ ctxt.sblk = NULL;
+ return ret;
}
static char *sqfs_basename(char *path)