summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-05-09 02:37:35 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-05-09 02:44:08 +0300
commit59ffaa41f0390914584f44293d5aed0a34e85b87 (patch)
treea83ff84ebc0a4788b7b46e9b51e7ec296c368cba
parent1db1773ec27fc4e7c9d44ad02ccfa7eaf364ce07 (diff)
downloadmpv-59ffaa41f0390914584f44293d5aed0a34e85b87.tar.bz2
mpv-59ffaa41f0390914584f44293d5aed0a34e85b87.tar.xz
video_out.c: Fix a minor memory leak
The code that loops over possible video output drivers and tries to find a working one does not free and reallocate the 'struct vo' if a driver's preinit() call fails, but just overwrites the same struct instead. This means that any memory the failing driver allocated as a talloc subcontext will not be freed immediately. This is not even a real leak as the memory will be freed once the VO is closed, but it's still nicer to free things immediately. Add talloc_free_children() to free any such talloc subcontexts that were created during the failing preinit().
-rw-r--r--libvo/video_out.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 73926c541e..7fd2fb21af 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -364,6 +364,7 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
free(name);
return vo; // success!
}
+ talloc_free_children(vo);
}
}
// continue...
@@ -380,6 +381,7 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
vo->driver = video_driver;
if (!vo_preinit(vo, vo_subdevice))
return vo; // success!
+ talloc_free_children(vo);
}
free(vo);
return NULL;