Re: [HelenOS-devel] Remove leak in tcp_pdu_encode
Hi Manuele, On 03/29/2016 12:10 PM, Manuele Conti wrote: > I found a memory leak in tcp_pdu_encode function and I try to fix it. I fixed this in mainline,2443 along with another leak and a missing check for failed tcp_header_encode(). Thanks, Jakub ___ HelenOS-devel mailing list HelenOS-devel@lists.modry.cz http://lists.modry.cz/listinfo/helenos-devel
[HelenOS-devel] Fix memory leak about mkmfs util
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 + +++ uspace/app/mkmfs/mkmfs.c 2016-03-30 11:03:04 + @@ -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,8 +672,11 @@ return rc; } - free(ibmap_buf); - free(zbmap_buf); +exit: + if (ibmap_buf) + free(ibmap_buf); + if (zbmap_buf) + free(zbmap_buf); return rc; } ___ HelenOS-devel mailing list HelenOS-devel@lists.modry.cz http://lists.modry.cz/listinfo/helenos-devel
Re: [HelenOS-devel] Fix memory leak about mkmfs util
On Wed, 2016-03-30 at 13:21 +0200, Manuele Conti wrote: > Hi All, > I found a memory leak in a mkmfs util and I try to fix it. free() is NULL safe (C std 7.20.3.2, and also in HelenOS uspace/lib/c/generic/malloc.c:972). doing: if (p) free(p); is useless. regards, Jan > > Regards, > Manuele > ___ > HelenOS-devel mailing list > HelenOS-devel@lists.modry.cz > http://lists.modry.cz/listinfo/helenos-devel signature.asc Description: This is a digitally signed message part ___ HelenOS-devel mailing list HelenOS-devel@lists.modry.cz http://lists.modry.cz/listinfo/helenos-devel
Re: [HelenOS-devel] Fix memory leak about mkmfs util
Hi Jan, You right tomorrow I'll resend my patch with your suggest. Many thanks, Manuele > On 30 Mar 2016, at 15:54, Jan Vesely wrote: > >> On Wed, 2016-03-30 at 13:21 +0200, Manuele Conti wrote: >> Hi All, >> I found a memory leak in a mkmfs util and I try to fix it. > > free() is NULL safe (C std 7.20.3.2, and also in HelenOS > uspace/lib/c/generic/malloc.c:972). doing: > > if (p) >free(p); > > is useless. > > regards, > Jan > >> >> Regards, >> Manuele >> ___ >> HelenOS-devel mailing list >> HelenOS-devel@lists.modry.cz >> http://lists.modry.cz/listinfo/helenos-devel > ___ > HelenOS-devel mailing list > HelenOS-devel@lists.modry.cz > http://lists.modry.cz/listinfo/helenos-devel ___ HelenOS-devel mailing list HelenOS-devel@lists.modry.cz http://lists.modry.cz/listinfo/helenos-devel
Re: [HelenOS-devel] Fix memory leak about mkmfs util
On 03/30/2016 03:54 PM, Jan Vesely wrote: > On Wed, 2016-03-30 at 13:21 +0200, Manuele Conti wrote: >> Hi All, >> I found a memory leak in a mkmfs util and I try to fix it. > > free() is NULL safe (C std 7.20.3.2, and also in HelenOS > uspace/lib/c/generic/malloc.c:972). doing: > > if (p) > free(p); > > is useless. But may result in faster code :-) Anyway, a little bit of explicitness here and there doesn't hurt. Jakub ___ HelenOS-devel mailing list HelenOS-devel@lists.modry.cz http://lists.modry.cz/listinfo/helenos-devel