summaryrefslogtreecommitdiff
path: root/jpg2ff.c
diff options
context:
space:
mode:
authorFRIGN <dev@frign.de>2016-03-18 19:49:11 +0100
committerFRIGN <dev@frign.de>2016-03-18 19:49:11 +0100
commite637aae67ededf6a4a0b4d490d02f3294f297b71 (patch)
tree8f09a69a6f68aed99205239f6eef1c11d3943b47 /jpg2ff.c
parent49cef794d9cef3c1ab8478963a7f778c8c28eb70 (diff)
Prevent overflow in rowlen and improve inaccuracies in style
Diffstat (limited to 'jpg2ff.c')
-rw-r--r--jpg2ff.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/jpg2ff.c b/jpg2ff.c
index dc5b060..8ebc81d 100644
--- a/jpg2ff.c
+++ b/jpg2ff.c
@@ -5,7 +5,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <jpeglib.h>
@@ -58,7 +57,7 @@ main(int argc, char *argv[])
jpgrow = (*js.mem->alloc_sarray)((j_common_ptr)&js,
JPOOL_IMAGE, width *
js.output_components, 1);
- rowlen = strlen("RGBA") * width;
+ rowlen = width * (sizeof("RGBA") - 1);
if(!(row = malloc(rowlen * sizeof(uint16_t)))) {
fprintf(stderr, "%s: malloc: out of memory\n", argv0);
return 1;
@@ -89,7 +88,7 @@ main(int argc, char *argv[])
}
/* write data */
- if (fwrite(row, 2, rowlen, stdout) != rowlen)
+ if (fwrite(row, sizeof(uint16_t), rowlen, stdout) != rowlen)
goto writerr;
}
jpeg_finish_decompress(&js);