diff options
author | Oz Linden <oz@lindenlab.com> | 2010-11-03 14:53:29 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2010-11-03 14:53:29 -0400 |
commit | e2714252f34b02ee628fb1665dfa90b932fab2f7 (patch) | |
tree | f595c3d581624a434b77e1774b5c7f71aa79f8e4 /indra/llimage | |
parent | 5d7417b40ed8717b3f307ed9e53c249a3a26cf1b (diff) | |
parent | 9d97a16481528acbfa28f7681da68a6e485f9a22 (diff) |
pull fix for STORM-422
Diffstat (limited to 'indra/llimage')
-rw-r--r-- | indra/llimage/llimagedimensionsinfo.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/indra/llimage/llimagedimensionsinfo.cpp b/indra/llimage/llimagedimensionsinfo.cpp index 5ea4a236b5..835664c60f 100644 --- a/indra/llimage/llimagedimensionsinfo.cpp +++ b/indra/llimage/llimagedimensionsinfo.cpp @@ -30,6 +30,9 @@ #include "llimagedimensionsinfo.h" +// Value is true if one of Libjpeg's functions has encountered an error while working. +static bool sJpegErrorEncountered = false; + bool LLImageDimensionsInfo::load(const std::string& src_filename,U32 codec) { clean(); @@ -101,9 +104,17 @@ bool LLImageDimensionsInfo::getImageDimensionsPng() return true; } +// Called instead of exit() if Libjpeg encounters an error. +void on_jpeg_error(j_common_ptr cinfo) +{ + (void) cinfo; + sJpegErrorEncountered = true; + llwarns << "Libjpeg has encountered an error!" << llendl; +} bool LLImageDimensionsInfo::getImageDimensionsJpeg() { + sJpegErrorEncountered = false; clean(); FILE *fp = fopen (mSrcFilename.c_str(), "rb"); if (fp == NULL) @@ -115,6 +126,9 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg() jpeg_error_mgr jerr; jpeg_decompress_struct cinfo; cinfo.err = jpeg_std_error(&jerr); + // Call our function instead of exit() if Libjpeg encounters an error. + // This is done to avoid crash in this case (STORM-472). + cinfo.err->error_exit = on_jpeg_error; jpeg_create_decompress (&cinfo); jpeg_stdio_src (&cinfo, fp); @@ -128,6 +142,6 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg() jpeg_destroy_decompress(&cinfo); fclose(fp); - return true; + return !sJpegErrorEncountered; } |