[Rawstudio-commit] r4043 - trunk/librawstudio

Anders Brander anders at brander.dk
Wed Sep 21 20:24:38 CEST 2011


Author: abrander
Date: 2011-09-21 20:24:38 +0200 (Wed, 21 Sep 2011)
New Revision: 4043

Modified:
   trunk/librawstudio/rs-rawfile.c
Log:
Fixed memory leaking problem with raw_open_file() when mmap() and friends fail (Reported by Ille).

Modified: trunk/librawstudio/rs-rawfile.c
===================================================================
--- trunk/librawstudio/rs-rawfile.c	2011-09-18 14:49:32 UTC (rev 4042)
+++ trunk/librawstudio/rs-rawfile.c	2011-09-21 18:24:38 UTC (rev 4043)
@@ -251,6 +251,7 @@
 
 	if ((rawfile->maphandle = CreateFileMapping(rawfile->filehandle, NULL, PAGE_READONLY, 0, 0, NULL))==NULL)
 	{
+		CloseHandle(rawfile->filehandle);
 		g_free(rawfile);
 		return(NULL);
 	}
@@ -258,6 +259,8 @@
 	rawfile->map = MapViewOfFile(rawfile->maphandle, FILE_MAP_READ, 0, 0, rawfile->size);
 	if (rawfile->map == NULL)
 	{
+		CloseHandle(rawfile->filehandle);
+		CloseHandle(rawfile->maphandle);
 		g_free(rawfile);
 		return(NULL);
 	}
@@ -271,6 +274,7 @@
 	rawfile->map = mmap(NULL, rawfile->size, PROT_READ, MAP_SHARED, fd, 0);
 	if(rawfile->map == MAP_FAILED)
 	{
+		close(fd);
 		g_free(rawfile);
 		return(NULL);
 	}




More information about the Rawstudio-commit mailing list