commit 9399f1a35ecbc22fc10b2aa6b03211bd8144f20b
parent 3edc68e2756e8be313582b326c36da6c7f989623
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 4 Jun 2015 16:14:58 +0200
Fix a memory leak
During the creation of a s3d_shape, we get a copy on its aw_material
that was not correctly released.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/s3daw.c b/src/s3daw.c
@@ -328,6 +328,8 @@ shapes_create(struct s3daw* s3daw, const char* filename)
} else {
size_t imtllib;
size_t dirname_len;
+ struct aw_material material;
+ AW(material_init(s3daw->allocator, &material));
/* Setup the `mtllib' buffer with the directory of the filename */
res = get_dirname(filename, &s3daw->mtllib);
@@ -357,8 +359,6 @@ shapes_create(struct s3daw* s3daw, const char* filename)
/* Register the materials of the material library */
AW(mtl_materials_count_get(s3daw->loader_mtl, &nmtls));
FOR_EACH(imtl, 0, nmtls) {
- struct aw_material material;
- AW(material_init(NULL, &material));
AW(mtl_material_get(s3daw->loader_mtl, imtl, &material));
res = htable_material_set(&s3daw->materials, &material.name, &material);
if(res != RES_OK) goto error;
@@ -378,6 +378,7 @@ shapes_create(struct s3daw* s3daw, const char* filename)
res = shape_register(s3daw, &s3daw->mtl);
if(res != RES_OK) goto error;
}
+ AW(material_release(&material));
}
exit: