From: nu774 Date: Mon, 7 Jan 2013 04:14:46 +0000 (+0900) Subject: check error of fread() and fwrite() X-Git-Tag: v0.0.6 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=5e1168a4dd21cd68e519448a442a2d90fcb15076;p=fdkaac.git check error of fread() and fwrite() --- diff --git a/src/main.c b/src/main.c index d32a2e5..f0521e4 100644 --- a/src/main.c +++ b/src/main.c @@ -33,13 +33,15 @@ static int read_callback(void *cookie, void *data, uint32_t size) { - return fread(data, 1, size, (FILE*)cookie); + size_t rc = fread(data, 1, size, (FILE*)cookie); + return ferror((FILE*)cookie) ? -1 : (int)rc; } static int write_callback(void *cookie, const void *data, uint32_t size) { - return fwrite(data, 1, size, (FILE*)cookie); + size_t rc = fwrite(data, 1, size, (FILE*)cookie); + return ferror((FILE*)cookie) ? -1 : (int)rc; } static @@ -297,7 +299,8 @@ int write_sample(FILE *ofp, m4af_writer_t *m4af, const void *data, uint32_t size, uint32_t duration) { if (!m4af) { - if (fwrite(data, 1, size, ofp) < 0) { + fwrite(data, 1, size, ofp); + if (ferror(ofp)) { fprintf(stderr, "ERROR: fwrite(): %s\n", strerror(errno)); return -1; } diff --git a/version.h b/version.h index 514ce14..edd1057 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #ifndef VERSION_H #define VERSION_H -const char *fdkaac_version = "0.0.5"; +const char *fdkaac_version = "0.0.6"; #endif