summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2014-02-26 09:40:19 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2014-02-26 09:40:19 +0000
commite231a84b2fdabc626458065842a293238653d0c0 (patch)
tree4de6f2a4ab85a21b31ae7f24fb2f324e44e0ba5b /src/bin
parentb56fb96b1b0feaa80890ed0a77b1d7d43ca2212f (diff)
[trunk] Properly store and use value returned by fread. Also invert nmemb and size in fread call.
Fixes issue 262
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/jp2/opj_compress.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
index 7b1c9471..da89e512 100644
--- a/src/bin/jp2/opj_compress.c
+++ b/src/bin/jp2/opj_compress.c
@@ -930,7 +930,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
float *lCurrentDoublePtr;
float *lSpace;
int *l_int_ptr;
- int lNbComp = 0, lTotalComp, lMctComp, i, lStrLen;
+ int lNbComp = 0, lTotalComp, lMctComp, i, lStrLen, lStrFread;
/* Open file */
FILE * lFile = fopen(lFilename,"r");
@@ -943,8 +943,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
lStrLen = ftell(lFile);
fseek(lFile,0,SEEK_SET);
lMatrix = (char *) malloc(lStrLen + 1);
- fread(lMatrix, lStrLen, 1, lFile);
+ lStrFread = fread(lMatrix, 1, lStrLen, lFile);
fclose(lFile);
+ if( lStrLen != lStrFread ) return 1;
lMatrix[lStrLen] = 0;
lCurrentPtr = lMatrix;