| To: | Mark Tinguely <tinguely@xxxxxxx> |
|---|---|
| Subject: | Re: [PATCH 15/14] xfs_io: free memory on error path exit from bmap_f() |
| From: | Eric Sandeen <sandeen@xxxxxxxxxxx> |
| Date: | Thu, 10 Apr 2014 09:15:51 -0500 |
| Cc: | Eric Sandeen <sandeen@xxxxxxxxxx>, xfs@xxxxxxxxxxx |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <53469EF0.3030407@xxxxxxx> |
| References: | <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx> <5345C751.8040803@xxxxxxxxxxx> <53469EF0.3030407@xxxxxxx> |
| User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
On 4/10/14, 8:38 AM, Mark Tinguely wrote:
> On 04/09/14 17:18, Eric Sandeen wrote:
>> If realloc() fails, the memory it was trying to realloc remains;
>> free it on the error path.
>>
>> Signed-off-by: Eric Sandeen<sandeen@xxxxxxxxxx>
>> ---
>>
>> diff --git a/io/bmap.c b/io/bmap.c
>> index a78cbb1..8e5d75e 100644
>> --- a/io/bmap.c
>> +++ b/io/bmap.c
>> @@ -227,6 +227,7 @@ bmap_f(
>> fprintf(stderr,
>> _("%s: cannot realloc %d bytes\n"),
>> progname, (int)(map_size*sizeof(*map)));
>> + free(map);
>> exitcode = 1;
>> return 0;
>> }
>
>
> Didn't it get into this block by comparing map to NULL?
Uh yes, yes we did. Sorry, was getting a bit slap-happy by then.
I guess p = realloc(p) will always lose the memory if it fails,
w/o a temporary var.
Sorry about that!
-Eric
> --Mark.
>
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH 15/14] xfs_io: free memory on error path exit from bmap_f(), Mark Tinguely |
|---|---|
| Next by Date: | [PATCH] xfstests: Fix generic/022 output file, Lukas Czerner |
| Previous by Thread: | Re: [PATCH 15/14] xfs_io: free memory on error path exit from bmap_f(), Mark Tinguely |
| Next by Thread: | Re: [PATCH 00/14] xfsprogs: varius & sundry fixes for coverity defects, Brian Foster |
| Indexes: | [Date] [Thread] [Top] [All Lists] |