Some fixes to memory leak bugs.
This commit is contained in:
parent
4c9d83f051
commit
26a04559c7
@ -7,6 +7,7 @@
|
|||||||
#include "libburn/libburn.h"
|
#include "libburn/libburn.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -83,6 +84,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
burn_src->free_data(burn_src);
|
burn_src->free_data(burn_src);
|
||||||
|
free(burn_src);
|
||||||
|
|
||||||
iso_image_unref(image);
|
iso_image_unref(image);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,7 +65,7 @@ int default_create_file(IsoNodeBuilder *builder, IsoImage *image,
|
|||||||
/* fill node fields */
|
/* fill node fields */
|
||||||
node->node.refcount = 1;
|
node->node.refcount = 1;
|
||||||
node->node.type = LIBISO_FILE;
|
node->node.type = LIBISO_FILE;
|
||||||
node->node.name = strdup(iso_file_source_get_name(src));
|
node->node.name = iso_file_source_get_name(src);
|
||||||
node->node.mode = S_IFREG | (info.st_mode & ~S_IFMT);
|
node->node.mode = S_IFREG | (info.st_mode & ~S_IFMT);
|
||||||
node->node.uid = info.st_uid;
|
node->node.uid = info.st_uid;
|
||||||
node->node.gid = info.st_gid;
|
node->node.gid = info.st_gid;
|
||||||
@ -117,12 +117,14 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
|||||||
IsoFile *file;
|
IsoFile *file;
|
||||||
result = iso_file_source_stream_new(src, &stream);
|
result = iso_file_source_stream_new(src, &stream);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
|
free(name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/* take a ref to the src, as stream has taken our ref */
|
/* take a ref to the src, as stream has taken our ref */
|
||||||
iso_file_source_ref(src);
|
iso_file_source_ref(src);
|
||||||
file = calloc(1, sizeof(IsoFile));
|
file = calloc(1, sizeof(IsoFile));
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
|
free(name);
|
||||||
iso_stream_unref(stream);
|
iso_stream_unref(stream);
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
@ -138,6 +140,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
|||||||
/* source is a directory */
|
/* source is a directory */
|
||||||
new = calloc(1, sizeof(IsoDir));
|
new = calloc(1, sizeof(IsoDir));
|
||||||
if (new == NULL) {
|
if (new == NULL) {
|
||||||
|
free(name);
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
new->type = LIBISO_DIR;
|
new->type = LIBISO_DIR;
|
||||||
@ -151,10 +154,12 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
|||||||
|
|
||||||
result = iso_file_source_readlink(src, dest, PATH_MAX);
|
result = iso_file_source_readlink(src, dest, PATH_MAX);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
|
free(name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
link = malloc(sizeof(IsoSymlink));
|
link = malloc(sizeof(IsoSymlink));
|
||||||
if (link == NULL) {
|
if (link == NULL) {
|
||||||
|
free(name);
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
link->dest = strdup(dest);
|
link->dest = strdup(dest);
|
||||||
@ -171,6 +176,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
|||||||
IsoSpecial *special;
|
IsoSpecial *special;
|
||||||
special = malloc(sizeof(IsoSpecial));
|
special = malloc(sizeof(IsoSpecial));
|
||||||
if (special == NULL) {
|
if (special == NULL) {
|
||||||
|
free(name);
|
||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
special->dev = info.st_rdev;
|
special->dev = info.st_rdev;
|
||||||
@ -182,7 +188,7 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
|||||||
|
|
||||||
/* fill fields */
|
/* fill fields */
|
||||||
new->refcount = 1;
|
new->refcount = 1;
|
||||||
new->name = strdup(name);
|
new->name = name;
|
||||||
new->mode = info.st_mode;
|
new->mode = info.st_mode;
|
||||||
new->uid = info.st_uid;
|
new->uid = info.st_uid;
|
||||||
new->gid = info.st_gid;
|
new->gid = info.st_gid;
|
||||||
|
@ -116,6 +116,7 @@ void iso_image_unref(IsoImage *image)
|
|||||||
libiso_msgs_destroy(&image->messenger, 0);
|
libiso_msgs_destroy(&image->messenger, 0);
|
||||||
iso_node_builder_unref(image->builder);
|
iso_node_builder_unref(image->builder);
|
||||||
iso_filesystem_unref(image->fs);
|
iso_filesystem_unref(image->fs);
|
||||||
|
free(image->recOpts);
|
||||||
free(image->volset_id);
|
free(image->volset_id);
|
||||||
free(image->volume_id);
|
free(image->volume_id);
|
||||||
free(image->publisher_id);
|
free(image->publisher_id);
|
||||||
@ -125,6 +126,7 @@ void iso_image_unref(IsoImage *image)
|
|||||||
free(image->copyright_file_id);
|
free(image->copyright_file_id);
|
||||||
free(image->abstract_file_id);
|
free(image->abstract_file_id);
|
||||||
free(image->biblio_file_id);
|
free(image->biblio_file_id);
|
||||||
|
free(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ int iso_tree_add_node_builder(IsoImage *image, IsoDir *parent,
|
|||||||
/* a node with same name already exists */
|
/* a node with same name already exists */
|
||||||
return ISO_NODE_NAME_NOT_UNIQUE;
|
return ISO_NODE_NAME_NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
|
free(name);
|
||||||
|
|
||||||
result = builder->create_node(builder, image, src, &new);
|
result = builder->create_node(builder, image, src, &new);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
@ -439,6 +440,9 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* name no more needed */
|
||||||
|
free(name);
|
||||||
|
|
||||||
/* ask user if callback has been set */
|
/* ask user if callback has been set */
|
||||||
if (image->recOpts->report) {
|
if (image->recOpts->report) {
|
||||||
action = image->recOpts->report(file, action, flag);
|
action = image->recOpts->report(file, action, flag);
|
||||||
|
Loading…
Reference in New Issue
Block a user