summaryrefslogtreecommitdiffstats
path: root/source4/lib/tdb/common/tdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-06-22 17:36:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:28 -0500
commit1f193bf76da65012a8529f93e6e21d558db15674 (patch)
treeffe247f5b5c95ea191804017eef826e071ad0a7d /source4/lib/tdb/common/tdb.c
parentf604ee43209921bca5f573d88cb232afc8756195 (diff)
downloadsamba-1f193bf76da65012a8529f93e6e21d558db15674.tar.gz
samba-1f193bf76da65012a8529f93e6e21d558db15674.tar.xz
samba-1f193bf76da65012a8529f93e6e21d558db15674.zip
r23590: Fix realloc leak on failure case from Jim Meyering <jim@meyering.net>.
Jeremy. (This used to be commit 59ba128cb61e77a830ddd8b8e1d5d0fd00f99736)
Diffstat (limited to 'source4/lib/tdb/common/tdb.c')
-rw-r--r--source4/lib/tdb/common/tdb.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c
index 70d050e7e6d..28129a8c8ed 100644
--- a/source4/lib/tdb/common/tdb.c
+++ b/source4/lib/tdb/common/tdb.c
@@ -579,8 +579,12 @@ int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf)
if (dbuf.dptr == NULL) {
dbuf.dptr = (unsigned char *)malloc(new_dbuf.dsize);
} else {
- dbuf.dptr = (unsigned char *)realloc(dbuf.dptr,
+ unsigned char *new_dptr = (unsigned char *)realloc(dbuf.dptr,
dbuf.dsize + new_dbuf.dsize);
+ if (new_dptr == NULL) {
+ free(dbuf.dptr);
+ }
+ dbuf.dptr = new_dptr;
}
if (dbuf.dptr == NULL) {