Don't segfault when tmpfile() fails.

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>
Merge branch origin/2.0.1

Conflicts:
	src/db_compact.c

Change-Id: I7864694a01bf6a6cfdb039a35702e78bdd8b51a3