Skip to content
Browse files

Fix a small bug where we trying to free NULL-ptr for root tree

  • Loading branch information...
1 parent fe1f916 commit ced33db764ff35e0bd35754391814e29602f4233 @jinlim jinlim committed Feb 23, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/couch_db.cc
View
3 src/couch_db.cc
@@ -950,7 +950,8 @@ int save_local_doc(Db* db, LocalDoc* lDoc)
new_local_docs_root = modify_btree(&rq, db->header.local_docs_root, &errcode);
if(errcode == 0 && new_local_docs_root != db->header.local_docs_root)
{
- free(db->header.local_docs_root);
+ if (db->header.local_docs_root)
+ free(db->header.local_docs_root);
@dustin
dustin added a note Mar 3, 2012

This doesn't actually change anything, free(NULL) is defined to be a NOOP.

Was there an actual bug here? Can we get a test that demonstrates it?

@jinlim
jinlim added a note Mar 3, 2012
@dustin
dustin added a note Mar 3, 2012

On what platform? POSIX defines free(NULL) behavior, so you were perhaps looking in the wrong place.

See the specification or just try it (also valid C++)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
db->header.local_docs_root = new_local_docs_root;
}
cleanup:

0 comments on commit ced33db

Please sign in to comment.
Something went wrong with that request. Please try again.