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)
s->eosin = !bytes && feof (s->in);
} while (!s->eosin);
- fclose (out);
+ success = true;
+
+cleanup:
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