projects
/
ruby-vorbistagger.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d167e47
)
Close and remove the temporary file if vcedit_write() fails.
author
Tilman Sauerbeck
<tilman@code-monkey.de>
Fri, 18 Aug 2006 13:45:19 +0000
(15:45 +0200)
committer
Tilman Sauerbeck
<tilman@code-monkey.de>
Wed, 23 Aug 2006 17:39:15 +0000
(19:39 +0200)
ext/vcedit.c
patch
|
blob
|
history
diff --git
a/ext/vcedit.c
b/ext/vcedit.c
index cf63e7487217c7a36fcb479590328488928c7c63..38ecb9f9d384818c84df6a0e96b85274fdd34767 100644
(file)
--- a/
ext/vcedit.c
+++ b/
ext/vcedit.c
@@
-403,6
+403,7
@@
vcedit_write (vcedit_state *s)
ogg_int64_t granpos = 0;
FILE *out;
char *buffer, tmpfile[PATH_MAX];
ogg_int64_t granpos = 0;
FILE *out;
char *buffer, tmpfile[PATH_MAX];
+ bool success = false;
int fd, result, bytes, needflush = 0, needout = 0;
if (!s->opened)
int fd, result, bytes, needflush = 0, needout = 0;
if (!s->opened)
@@
-546,13
+547,20
@@
vcedit_write (vcedit_state *s)
s->eosin = !bytes && feof (s->in);
} while (!s->eosin);
s->eosin = !bytes && feof (s->in);
} while (!s->eosin);
- fclose (out);
+ success = true;
+
+cleanup:
fclose (s->in);
fclose (s->in);
- unlink (s->filename);
- rename (tmpfile, s->filename);
+ if (!success) {
+ unlink (tmpfile);
+ fclose (out);
+ } else {
+ fclose (out);
+ unlink (s->filename);
+ rename (tmpfile, s->filename);
+ }
-cleanup:
ogg_stream_clear (&streamout);
/* We don't ogg_packet_clear() this, because the memory was
ogg_stream_clear (&streamout);
/* We don't ogg_packet_clear() this, because the memory was