[PATCH] Simplify frees in load_vob_subtitle.

Clément Bœsch ubitux at gmail.com
Mon Jan 24 08:31:29 CET 2011


---
 sub/subreader.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sub/subreader.c b/sub/subreader.c
index 216b094..8053ea8 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -2161,10 +2161,8 @@ void load_vob_subtitle(const char *fname, const char * const ifo, void **spu,
     if (!name)
         return;
     strcpy_strip_ext(name, fname);
-    if (add_f(name, ifo, 0, spu)) {
-        free(name);
-        return;
-    }
+    if (add_f(name, ifo, 0, spu))
+        goto out;
 
     // Try looking at the dirs specified by sub-paths option
     if (sub_paths) {
@@ -2172,6 +2170,7 @@ void load_vob_subtitle(const char *fname, const char * const ifo, void **spu,
 
         for (i = 0; sub_paths[i]; i++) {
             char *path, *psub;
+            int sub_found;
 
             path = mp_path_join(fname, sub_paths[i]);
             if (!path)
@@ -2182,11 +2181,10 @@ void load_vob_subtitle(const char *fname, const char * const ifo, void **spu,
             if (!psub)
                 goto out;
 
-            if (add_f(psub, ifo, 0, spu)) {
-                free(psub);
-                goto out;
-            }
+            sub_found = add_f(psub, ifo, 0, spu);
             free(psub);
+            if (sub_found)
+                goto out;
         }
     }
 
@@ -2194,6 +2192,8 @@ void load_vob_subtitle(const char *fname, const char * const ifo, void **spu,
     mp_subdir = get_path("sub/");
     if (mp_subdir) {
         char *psub = mp_path_join(mp_subdir, mp_basename(name));
+        if (!psub)
+            goto out;
         add_f(psub, ifo, 0, spu);
         free(psub);
     }
-- 
1.7.4


--qGV0fN9tzfkG3CxV--


More information about the MPlayer-dev-eng mailing list