Closed memory leak with memory shortage while creating IsoSymlink object.

Coverity CID 12575.
This commit is contained in:
Thomas Schmitt 2015-10-10 11:05:41 +02:00
parent a6542e5fa9
commit d04abdcfbd

View File

@ -106,11 +106,11 @@ static
int default_create_node(IsoNodeBuilder *builder, IsoImage *image, int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
IsoFileSource *src, char *in_name, IsoNode **node) IsoFileSource *src, char *in_name, IsoNode **node)
{ {
int ret; int ret, name_is_attached = 0;
struct stat info; struct stat info;
IsoNode *new; IsoNode *new;
IsoFilesystem *fs; IsoFilesystem *fs;
char *name; char *name = NULL;
unsigned char *aa_string = NULL; unsigned char *aa_string = NULL;
char *a_text = NULL, *d_text = NULL; char *a_text = NULL, *d_text = NULL;
char *dest = NULL; char *dest = NULL;
@ -217,10 +217,9 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
break; break;
} }
if (ret < 0) { if (ret < 0)
free(name);
goto ex; goto ex;
} name_is_attached = 1;
/* fill fields */ /* fill fields */
iso_node_set_perms_internal(new, info.st_mode, 1); iso_node_set_perms_internal(new, info.st_mode, 1);
@ -263,6 +262,8 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
ret = ISO_SUCCESS; ret = ISO_SUCCESS;
ex:; ex:;
if (name != NULL && !name_is_attached)
free(name);
LIBISO_FREE_MEM(dest); LIBISO_FREE_MEM(dest);
return ret; return ret;
} }