Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in imagetopnm of convert.c in case image->comps[].data is NULL #1156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/bin/jp2/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,14 +2021,26 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
int *red, *green, *blue, *alpha;
int wr, hr, max;
int i;
unsigned int compno, ncomp;
unsigned int compno, ncomp, ui;
int adjustR, adjustG, adjustB, adjustA;
int fails, two, want_gray, has_alpha, triple;
int prec, v;
FILE *fdest = NULL;
const char *tmp = outfile;
char *destname;

fails = 0;
ncomp = image->numcomps;
for (ui = 0; ui < ncomp; ++ui) {
if (image->comps[ui].data == NULL) {
fprintf(stderr, "imagetopnm data[%u] == NULL\n", ui);
fails = 1;
}
}
if (fails) {
return 1;
}

alpha = NULL;

if ((prec = (int)image->comps[0].prec) > 16) {
Expand Down
21 changes: 17 additions & 4 deletions src/bin/jp2/opj_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,25 @@ static int infile_format(const char *fname)
return ext_format;
}

s = fname + strlen(fname) - 4;
s = fname + strlen(fname) - 1;

fputs("\n===========================================\n", stderr);
#ifdef WIN32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is legal to use forward slash on Windows too: c:/users/bla/...

while (s > fname && (*s != '.' && *s != '\\')) {
--s;
}
#else
while (s > fname && (*s != '.' && *s != '/')) {
--s;
}
#endif
if (*s != '.') {
s = "";
}

fputs("\n===============================================\n", stderr);
fprintf(stderr, "The extension of this file is incorrect.\n"
"FOUND %s. SHOULD BE %s\n", s, magic_s);
fputs("===========================================\n", stderr);
" FOUND '%s'. SHOULD BE '%s'", s, magic_s);
fputs("\n===============================================\n", stderr);

return magic_format;
}
Expand Down