summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-08-29 21:52:40 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-08-30 11:52:40 +1000
commit499ab821ea6bd8db5369d9951be9b4f372e2c89e (patch)
tree46776468b9c212c4926bbeb49d58b7e7e8236247
parent3827366c7acd36129bc83aa65fd9fbbb527e0af4 (diff)
downloadmongo-499ab821ea6bd8db5369d9951be9b4f372e2c89e.tar.gz
SERVER-25845 Coverity analysis defect 99859: Explicit null dereferenced (#2996)
False positive, Coverity thinks we can dereference a NULL. Rewrite the function to use a local variable instead of the passed-in address, that sometimes helps Coverity understand.
-rw-r--r--src/btree/row_modify.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/btree/row_modify.c b/src/btree/row_modify.c
index f37c77d284f..a1c214e5b8b 100644
--- a/src/btree/row_modify.c
+++ b/src/btree/row_modify.c
@@ -267,23 +267,27 @@ int
__wt_update_alloc(
WT_SESSION_IMPL *session, WT_ITEM *value, WT_UPDATE **updp, size_t *sizep)
{
+ WT_UPDATE *upd;
size_t size;
+ *updp = NULL;
+
/*
* Allocate the WT_UPDATE structure and room for the value, then copy
* the value into place.
*/
size = value == NULL ? 0 : value->size;
- WT_RET(__wt_calloc(session, 1, sizeof(WT_UPDATE) + size, updp));
+ WT_RET(__wt_calloc(session, 1, sizeof(WT_UPDATE) + size, &upd));
if (value == NULL)
- WT_UPDATE_DELETED_SET(*updp);
+ WT_UPDATE_DELETED_SET(upd);
else {
- (*updp)->size = WT_STORE_SIZE(size);
+ upd->size = WT_STORE_SIZE(size);
if (size != 0)
- memcpy(WT_UPDATE_DATA(*updp), value->data, size);
+ memcpy(WT_UPDATE_DATA(upd), value->data, size);
}
- *sizep = WT_UPDATE_MEMSIZE(*updp);
+ *updp = upd;
+ *sizep = WT_UPDATE_MEMSIZE(upd);
return (0);
}