Skip to content

Commit

Permalink
Don't segfault when tmpfile() fails.
Browse files Browse the repository at this point in the history
Fixes bug-143 http://cbugg.hq.couchbase.com/bug/bug-143

If tmpfile() returns NULL, return COUCHSTORE_ERROR_OPEN_FILE. This can
happen if /tmp is not writable by Couchbase, as seen in JIRA MB-7587.

Change-Id: Ie67c342f3b56aa890e025b4eb747dcec385d80c6
Reviewed-on: http://review.couchbase.org/24169
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Fulu Li <fulu@couchbase.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
  • Loading branch information
apage43 committed Feb 1, 2013
1 parent 162935b commit 146c965
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/db_compact.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ couchstore_error_t couchstore_compact_db_ex(Db* source, const char* target_filen

if(source->header.by_seq_root) {
ctx.id_tmp = tmpfile();
if(!ctx.id_tmp) {
error_pass(COUCHSTORE_ERROR_OPEN_FILE);
}
error_pass(compact_seq_tree(source, target, &ctx));
error_pass(write_id_tree(target, &ctx));
fclose(ctx.id_tmp);
Expand Down

0 comments on commit 146c965

Please sign in to comment.