summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@gmail.com>2014-04-02 16:25:40 +0000
committerAntonin Descampe <antonin@gmail.com>2014-04-02 16:25:40 +0000
commit4db4198722efd5c18c55e9216489f505884cafc3 (patch)
tree44568e3b43115e36282102806d79b47e8ac738f6 /src
parent616a3345c45e2cd800778880b2b10bc868edbe41 (diff)
[trunk] fixed a bug triggering SEGFAULT on debug mode (uninitialized
structure)
Diffstat (limited to 'src')
-rw-r--r--src/bin/jp2/opj_compress.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
index 5957a467..bfa8429c 100644
--- a/src/bin/jp2/opj_compress.c
+++ b/src/bin/jp2/opj_compress.c
@@ -587,7 +587,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
substr1 = (char*) malloc((len+1)*sizeof(char));
memcpy(substr1,opj_optarg,len);
substr1[len] = '\0';
- if (sscanf(substr1, "%d,%d,%d,%d,%[su]", &width, &height, &ncomp, &bitdepth, &signo) == 5) {
+ if (sscanf(substr1, "%d,%d,%d,%d,%c", &width, &height, &ncomp, &bitdepth, &signo) == 5) {
if (signo == 's') {
raw_signed = OPJ_TRUE;
} else if (signo == 'u') {
@@ -636,6 +636,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
}
}
}
+ if (substr1) free(substr1);
if (wrong) {
fprintf(stderr,"\nError: invalid raw image parameters\n");
fprintf(stderr,"Please use the Format option -F:\n");
@@ -646,7 +647,6 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
fprintf(stderr,"Aborting.\n");
return 1;
}
- if (substr1 != NULL) free(substr1);
}
break;
@@ -1526,6 +1526,14 @@ int main(int argc, char **argv) {
*indexfilename = 0;
memset(&img_fol,0,sizeof(img_fol_t));
+ /* raw_cp initialization */
+ raw_cp.rawBitDepth = 0;
+ raw_cp.rawComp = 0;
+ raw_cp.rawComps = 0;
+ raw_cp.rawHeight = 0;
+ raw_cp.rawSigned = 0;
+ raw_cp.rawWidth = 0;
+
/* parse input and get user encoding parameters */
parameters.tcp_mct = (char) 255; /* This will be set later according to the input image or the provided option */
if(parse_cmdline_encoder(argc, argv, &parameters,&img_fol, &raw_cp, indexfilename) == 1) {