diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-11-08 09:52:42 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-11-08 09:52:42 -0500 |
commit | 9ae1c6fd13f0f6d808b11864056f0a570847c364 (patch) | |
tree | fab4bc56432d00b83649a83815dfccdfe834bd38 /indra/llimage | |
parent | ab42f31608a2abc0982119d6aebdb0972d41427f (diff) | |
parent | 124a59263184391b0b4ec418c532b7a715e9b5a3 (diff) |
Automated merge up from viewer-development
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; } |