From 70530ad551620100480c8cdef2654790fc524a02 Mon Sep 17 00:00:00 2001 From: szaka Date: Mon, 27 Jun 2005 20:30:09 +0000 Subject: [PATCH] ntfs_inode_close(): ElectricFence is unhappy with realloc(x,0) as free(x) thus we distinguish these two cases --- libntfs/inode.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libntfs/inode.c b/libntfs/inode.c index c9e02760..cbab29fe 100644 --- a/libntfs/inode.c +++ b/libntfs/inode.c @@ -249,13 +249,19 @@ int ntfs_inode_close(ntfs_inode *ni) memmove(tmp_nis + i, tmp_nis + i + 1, (base_ni->nr_extents - i - 1) * sizeof(ntfs_inode *)); - base_ni->nr_extents--; - /* Resize the memory buffer. */ - tmp_nis = realloc(tmp_nis, base_ni->nr_extents * - sizeof(ntfs_inode *)); - /* Ignore realloc errors, they don't really matter. */ - if (tmp_nis) - base_ni->extent_nis = tmp_nis; + /* + * ElectricFence is unhappy with realloc(x,0) as free(x) + * thus we explicitely separate these two cases. + */ + if (--base_ni->nr_extents) { + /* Resize the memory buffer. */ + tmp_nis = realloc(tmp_nis, base_ni->nr_extents * + sizeof(ntfs_inode *)); + /* Ignore errors, they don't really matter. */ + if (tmp_nis) + base_ni->extent_nis = tmp_nis; + } else if(tmp_nis) + free(tmp_nis); /* Allow for error checking. */ i = -1; break;