X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=blobdiff_plain;f=tools%2Fcws2fws.c;h=72980f4e2df796a0a7446eb6313fb6a606d19bd7;hp=68f7953b56bf04a705303147f037306ab49ed7d9;hb=604fbb3132e88727e496c96c92cfe02748c25a1a;hpb=4e81b5f517443c0e60df3f2c6ddc8cac96a34af8 diff --git a/tools/cws2fws.c b/tools/cws2fws.c index 68f7953b56..72980f4e2d 100644 --- a/tools/cws2fws.c +++ b/tools/cws2fws.c @@ -6,11 +6,17 @@ * This utility converts compressed Macromedia Flash files to uncompressed ones. */ +#include "config.h" #include #include #include #include +#if HAVE_UNISTD_H #include +#endif +#if HAVE_IO_H +#include +#endif #include #ifdef DEBUG @@ -25,6 +31,7 @@ int main(int argc, char *argv[]) char buf_in[1024], buf_out[65536]; z_stream zstream; struct stat statbuf; + int ret = 1; if (argc < 3) { printf("Usage: %s \n", argv[0]); @@ -46,14 +53,12 @@ int main(int argc, char *argv[]) if (read(fd_in, &buf_in, 8) != 8) { printf("Header error\n"); - close(fd_in); - close(fd_out); - return 1; + goto out; } if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') { printf("Not a compressed flash file\n"); - return 1; + goto out; } fstat(fd_in, &statbuf); @@ -67,7 +72,7 @@ int main(int argc, char *argv[]) buf_in[0] = 'F'; if (write(fd_out, &buf_in, 8) < 8) { perror("Error writing output file"); - return 1; + goto out; } zstream.zalloc = NULL; @@ -91,7 +96,7 @@ int main(int argc, char *argv[]) if (ret != Z_STREAM_END && ret != Z_OK) { printf("Error while decompressing: %d\n", ret); inflateEnd(&zstream); - return 1; + goto out; } dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n", @@ -101,7 +106,8 @@ int main(int argc, char *argv[]) if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) { perror("Error writing output file"); - return 1; + inflateEnd(&zstream); + goto out; } i += len; @@ -122,12 +128,15 @@ int main(int argc, char *argv[]) lseek(fd_out, 4, SEEK_SET); if (write(fd_out, &buf_in, 4) < 4) { perror("Error writing output file"); - return 1; + inflateEnd(&zstream); + goto out; } } + ret = 0; inflateEnd(&zstream); +out: close(fd_in); close(fd_out); - return 0; + return ret; }