database.c: fix: set return value to -1 in case of error