[DVDnav-discuss] r1288 - trunk/libdvdread/src/dvd_udf.c

rathann subversion at mplayerhq.hu
Tue Nov 19 00:43:16 CET 2013


Author: rathann
Date: Tue Nov 19 00:43:16 2013
New Revision: 1288

Log:
Free `cached_dir_base` to fix memory leak

The static analyzer from LLVM/Clang 1:3.4~svn194079-1 reports a memory
leak in `libdvdread/src/dvd_udf.c`.

        $ scan-build -o scan-build make
        $ scan-view scan-build/2013-11-18-155601-16168-1

The memory is allocated in

       	if((cached_dir_base = malloc(dir_lba * DVD_VIDEO_LB_LEN + 2048)) == NULL)

and has to be freed before returning from the function.

Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>

Modified:
   trunk/libdvdread/src/dvd_udf.c

Modified: trunk/libdvdread/src/dvd_udf.c
==============================================================================
--- trunk/libdvdread/src/dvd_udf.c	Sun Nov 17 01:16:02 2013	(r1287)
+++ trunk/libdvdread/src/dvd_udf.c	Tue Nov 19 00:43:16 2013	(r1288)
@@ -594,8 +594,10 @@ static int UDFScanDir( dvd_reader_t *dev
     } else
       in_cache = 1;
 
-    if(cached_dir == NULL)
+    if(cached_dir == NULL) {
+      free(cached_dir_base);
       return 0;
+    }
 
     p = 0;
 


More information about the DVDnav-discuss mailing list