diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-02-28 18:13:24 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-02-28 18:13:24 +0100 |
commit | 6c2044f1e445f79d4685b471af2d9e80c009395d (patch) | |
tree | 1f9aed41b3a822b6d64d2a40dac04e8169cf5c5b | |
parent | 5b052c73fee8dcb9e6cabe136b7cbe35269429c8 (diff) | |
download | ufodecode-6c2044f1e445f79d4685b471af2d9e80c009395d.tar.gz ufodecode-6c2044f1e445f79d4685b471af2d9e80c009395d.tar.bz2 ufodecode-6c2044f1e445f79d4685b471af2d9e80c009395d.tar.xz ufodecode-6c2044f1e445f79d4685b471af2d9e80c009395d.zip |
Fix segfault for big sensor data
-rw-r--r-- | test/ipedec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/ipedec.c b/test/ipedec.c index 9b8b0e0..04d3d98 100644 --- a/test/ipedec.c +++ b/test/ipedec.c @@ -8,6 +8,8 @@ #include <getopt.h> #include <ufodecode.h> +static const int MAX_ROWS = 2048; + typedef struct { int clear_frame; int dry_run; @@ -176,13 +178,13 @@ process_file(const char *filename, Options *opts) } timer = timer_new (); - pixels = (uint16_t *) malloc(2048 * 1088 * sizeof(uint16_t)); + pixels = (uint16_t *) malloc(2048 * MAX_ROWS * sizeof(uint16_t)); n_frames = 0; old_time_stamp = 0; while (error != EIO) { if (opts->clear_frame) - memset(pixels, 0, 2048 * 1088 * sizeof(uint16_t)); + memset(pixels, 0, 2048 * opts->rows * sizeof(uint16_t)); timer_start (timer); error = ufo_decoder_get_next_frame(decoder, &pixels, &meta); @@ -210,7 +212,7 @@ process_file(const char *filename, Options *opts) printf("\n"); if (!opts->dry_run) - fwrite(pixels, sizeof(uint16_t), 2048 * 1088, fp); + fwrite(pixels, sizeof(uint16_t), 2048 * opts->rows , fp); } else if (error != EIO) { fprintf(stderr, "Failed to decode frame %i\n", n_frames); @@ -218,7 +220,7 @@ process_file(const char *filename, Options *opts) if (opts->cont) { /* Save the frame even though we know it is corrupted */ if (!opts->dry_run) - fwrite(pixels, sizeof(uint16_t), 2048 * 1088, fp); + fwrite(pixels, sizeof(uint16_t), 2048 * opts->rows, fp); } else break; |