From 9f85cb63595bcb933a3af6b097510dd2980a61ec Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Tue, 10 Oct 2006 00:40:17 +0000 Subject: [PATCH] fix problem with code that checks if temp file is needed, before it would compare filenames, now it compares inodes --- src/flac/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/flac/main.c b/src/flac/main.c index 88a53b5a..426fe277 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -1777,9 +1777,10 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ common_options.debug.disable_fixed_subframes = option_values.debug.disable_fixed_subframes; common_options.debug.disable_verbatim_subframes = option_values.debug.disable_verbatim_subframes; - /* if infilename==outfilename, we need to write to a temporary file */ - if(encode_infile != stdin && 0 == strcmp(infilename, outfilename)) { /*@@@@@@ BUG strcmp is not adequate to check if infilename and outfilename are the same file */ - static const char *tmp_suffix = ".tmp"; + /* if infilename and outfilename point to the same file, we need to write to a temporary file */ + if(encode_infile != stdin && grabbag__file_are_same(infilename, outfilename)) { + static const char *tmp_suffix = ".tmp,fl-ac+en'c"; + /*@@@ still a remote possibility that a file with this filename exists */ if(0 == (internal_outfilename = malloc(strlen(outfilename)+strlen(tmp_suffix)+1))) { flac__utils_printf(stderr, 1, "ERROR allocating memory for tempfile name\n"); return 1;