Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-10-15 09:45:53 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-15 09:45:53 +0300
commita595cda2cdb4f4004b478a00ca3d0f674c0e8b1a (patch)
tree18f662b014a96a110b38317b3b0f98d48478f94c /source/blender
parent0be6ca0b839ffc28d02b9e1bd50cdd81df3b6aeb (diff)
Fix memory leaks in PlayAnim
Was never freeing filenames or pictures.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 5e223144530..31690f8a6ae 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -383,7 +383,6 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
// short val;
PlayAnimPict *picture = NULL;
struct ImBuf *ibuf = NULL;
- char str[32 + FILE_MAX];
struct anim *anim;
if (IMB_isanim(first)) {
@@ -402,8 +401,7 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
picture->anim = anim;
picture->frame = pic;
picture->IB_flags = IB_rect;
- BLI_snprintf(str, sizeof(str), "%s : %4.d", first, pic + 1);
- picture->name = strdup(str);
+ picture->name = BLI_sprintfN("%s : %4.d", first, pic + 1);
BLI_addtail(&picsbase, picture);
}
}
@@ -480,8 +478,8 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
}
picture->mem = mem;
- picture->name = strdup(filepath);
- picture->frame = count; /* not exact but should work for positioning */
+ picture->name = BLI_strdup(filepath);
+ picture->frame = count;
close(file);
BLI_addtail(&picsbase, picture);
count++;
@@ -1102,7 +1100,6 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
GHOST_TUns32 maxwinx, maxwiny;
int i;
/* This was done to disambiguate the name for use under c++. */
- struct anim *anim = NULL;
int start_x = 0, start_y = 0;
int sfra = -1;
int efra = -1;
@@ -1209,6 +1206,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
if (IMB_isanim(filepath)) {
/* OCIO_TODO: support different input color spaces */
+ struct anim *anim;
anim = IMB_open_anim(filepath, IB_rect, 0, NULL);
if (anim) {
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
@@ -1480,13 +1478,13 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
}
}
}
- ps.picture = picsbase.first;
- anim = NULL;
- while (ps.picture) {
- if (ps.picture && ps.picture->anim && (anim != ps.picture->anim)) {
- // to prevent divx crashes
- anim = ps.picture->anim;
- IMB_close_anim(anim);
+ while ((ps.picture = BLI_pophead(&picsbase))) {
+ if (ps.picture->anim) {
+ if ((ps.picture->next == NULL) ||
+ (ps.picture->next->anim != ps.picture->anim))
+ {
+ IMB_close_anim(ps.picture->anim);
+ }
}
if (ps.picture->ibuf) {
@@ -1496,7 +1494,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
MEM_freeN(ps.picture->mem);
}
- ps.picture = ps.picture->next;
+ MEM_freeN((void *)ps.picture->name);
+ MEM_freeN(ps.picture);
}
/* cleanup */