xfs
[Top] [All Lists]

[PATCH 15/14] xfs_io: free memory on error path exit from bmap_f()

To: Eric Sandeen <sandeen@xxxxxxxxxx>, xfs@xxxxxxxxxxx
Subject: [PATCH 15/14] xfs_io: free memory on error path exit from bmap_f()
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Wed, 09 Apr 2014 17:18:57 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx>
References: <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
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;
                        }


<Prev in Thread] Current Thread [Next in Thread>