Index: src/book.c =================================================================== --- src/book.c.orig +++ src/book.c @@ -343,9 +343,11 @@ int BookBuilderOpen(void) } digest_bits = MAX_DIGEST_BITS; /* We use read_book() here only to allocate memory */ - if (read_book(wfp) == BOOK_ENOMEM) { + if (read_book(rfp) == BOOK_ENOMEM) { + fclose(rfp); return BOOK_ENOMEM; } + fclose(rfp); } return BOOK_SUCCESS; }