Skip to content

Commit

Permalink
Make sure we don't call jpeg_destroy_[de]compress() on an uninitializ…
Browse files Browse the repository at this point in the history
…ed struct, as bad mojo can ensue.

git-svn-id: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk@714 3789f03b-4d11-0410-bbf8-ca57d06f2519
  • Loading branch information
dcommander committed Oct 18, 2011
1 parent 36cafd5 commit 845ebcf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bmp.c
Expand Up @@ -107,6 +107,8 @@ int loadbmp(char *filename, unsigned char **buf, int *w, int *h,
cjpeg_source_ptr src;
FILE *file=NULL;

memset(&cinfo, 0, sizeof(struct jpeg_compress_struct));

if(!filename || !buf || !w || !h || dstpf<0 || dstpf>=TJ_NUMPF)
_throw("loadbmp(): Invalid argument");

Expand Down Expand Up @@ -189,6 +191,8 @@ int savebmp(char *filename, unsigned char *buf, int w, int h, int srcpf,
FILE *file=NULL;
char *ptr=NULL;

memset(&dinfo, 0, sizeof(struct jpeg_decompress_struct));

if(!filename || !buf || w<1 || h<1 || srcpf<0 || srcpf>=TJ_NUMPF)
_throw("savebmp(): Invalid argument");

Expand Down

0 comments on commit 845ebcf

Please sign in to comment.