summaryrefslogtreecommitdiff
path: root/source3
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 12:23:33 -0500
commited961d66b242c9f3a32c0b8cbb765771f8c30c00 (patch)
tree3abbffb20e019c59474959fcadcf216a046c7842 /source3
parent08a9de8927bbca982be4e566e56748045defc1c7 (diff)
downloadsamba-ed961d66b242c9f3a32c0b8cbb765771f8c30c00.tar.gz
samba-ed961d66b242c9f3a32c0b8cbb765771f8c30c00.tar.bz2
samba-ed961d66b242c9f3a32c0b8cbb765771f8c30c00.zip
r23590: Fix realloc leak on failure case from Jim Meyering <jim@meyering.net>.
Jeremy. (This used to be commit d7b39e4534d85c84e8b24668ab7d7a93d5647c23)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/tdb/common/tdb.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/source3/lib/tdb/common/tdb.c b/source3/lib/tdb/common/tdb.c
index 25103d826e..dce6b58ac8 100644
--- a/source3/lib/tdb/common/tdb.c
+++ b/source3/lib/tdb/common/tdb.c
@@ -566,8 +566,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) {