X-Git-Url: http://git.scottworley.com/overonion/blobdiff_plain/3adfbe9d667f73d8049153e924fb65886ebb67b6..a99e77b43df141c988b52e663d64d40e79f11895:/reverse_test.c?ds=sidebyside diff --git a/reverse_test.c b/reverse_test.c index fe35bcc..512edaa 100644 --- a/reverse_test.c +++ b/reverse_test.c @@ -13,8 +13,10 @@ char* reverse_to_temp_file(const char* input_file) { char* temp_filename = strdup("/tmp/reverse_test.XXXXXX"); int fd = mkstemp(temp_filename); if (fd == -1) err(EX_IOERR, "Couldn't make a temporary file"); - reverse_file(input_file, fd); - if (close(fd) == -1) err(EX_IOERR, "Couldn't close temporary file"); + FILE* f = fdopen(fd, "w"); + if (f == NULL) err(EX_IOERR, "Couldn't open temporary file"); + reverse_file(input_file, f); + if (fclose(f) == EOF) err(EX_IOERR, "Couldn't close temporary file"); return temp_filename; }