[MPlayer-cvslog] r36634 - trunk/sub/vobsub.c

reimar subversion at mplayerhq.hu
Sun Jan 19 14:14:41 CET 2014


Author: reimar
Date: Sun Jan 19 14:14:41 2014
New Revision: 36634

Log:
vobsub: Simplify and fix memleak.

Modified:
   trunk/sub/vobsub.c

Modified: trunk/sub/vobsub.c
==============================================================================
--- trunk/sub/vobsub.c	Sun Jan 19 13:06:04 2014	(r36633)
+++ trunk/sub/vobsub.c	Sun Jan 19 14:14:41 2014	(r36634)
@@ -1229,12 +1229,13 @@ void *vobsub_out_open(const char *basena
                       unsigned int orig_width, unsigned int orig_height,
                       const char *id, unsigned int index)
 {
-    vobsub_out_t *result = NULL;
-    char *filename;
-    filename = malloc(strlen(basename) + 5);
-    if (filename) {
-        result = malloc(sizeof(vobsub_out_t));
-        if (result) {
+    vobsub_out_t *result = calloc(1, sizeof(*result));
+    char *filename = malloc(strlen(basename) + 5);
+    if (!filename || !result) {
+        free(filename);
+        free(result);
+        return NULL;
+    }
             result->aid = index;
             strcpy(filename, basename);
             strcat(filename, ".sub");
@@ -1256,8 +1257,6 @@ void *vobsub_out_open(const char *basena
             } else
                 perror("Error: vobsub_out_open index file open failed");
             free(filename);
-        }
-    }
     return result;
 }
 


More information about the MPlayer-cvslog mailing list