Hi all,
this is my patch file without check null pointer before free call.

Cheers,
Manuele


2016-03-30 13:21 GMT+02:00 Manuele Conti <[email protected]>:

> Hi All,
> I found a memory leak in a mkmfs util and I try to fix it.
>
> Regards,
> Manuele
>
=== modified file 'uspace/app/mkmfs/mkmfs.c'
--- uspace/app/mkmfs/mkmfs.c	2015-08-22 05:12:30 +0000
+++ uspace/app/mkmfs/mkmfs.c	2016-04-01 07:09:07 +0000
@@ -639,8 +639,10 @@
 	ibmap_buf = malloc(ibmap_nblocks * sb->block_size);
 	zbmap_buf = malloc(zbmap_nblocks * sb->block_size);
 
-	if (!ibmap_buf || !zbmap_buf)
-		return ENOMEM;
+	if (!ibmap_buf || !zbmap_buf) {
+		rc = ENOMEM;
+		goto exit;
+	}
 
 	memset(ibmap_buf, 0xFF, ibmap_nblocks * sb->block_size);
 	memset(zbmap_buf, 0xFF, zbmap_nblocks * sb->block_size);
@@ -670,6 +672,7 @@
 			return rc;
 	}
 
+exit:
 	free(ibmap_buf);
 	free(zbmap_buf);
 

_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel

Reply via email to