зеркало из https://github.com/mozilla/gecko-dev.git
Bug 392867 - libpng requires error callbacks to not return. Separate out nsPNGDecoder's ErrorCallback and WarningCallback, and call longjmp from ErrorCallback. r=joe a=ehsan
This commit is contained in:
Родитель
4ca29b52ef
Коммит
addacc9046
|
@ -147,7 +147,7 @@ NS_IMETHODIMP nsPNGEncoder::StartImageEncode(PRUint32 aWidth,
|
|||
mPNG = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
nsnull,
|
||||
ErrorCallback,
|
||||
ErrorCallback);
|
||||
WarningCallback);
|
||||
if (! mPNG)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -665,10 +665,10 @@ nsPNGEncoder::StripAlpha(const PRUint8* aSrc, PRUint8* aDest,
|
|||
}
|
||||
|
||||
|
||||
// nsPNGEncoder::ErrorCallback
|
||||
// nsPNGEncoder::WarningCallback
|
||||
|
||||
void // static
|
||||
nsPNGEncoder::ErrorCallback(png_structp png_ptr,
|
||||
nsPNGEncoder::WarningCallback(png_structp png_ptr,
|
||||
png_const_charp warning_msg)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -679,6 +679,25 @@ nsPNGEncoder::ErrorCallback(png_structp png_ptr,
|
|||
}
|
||||
|
||||
|
||||
// nsPNGEncoder::ErrorCallback
|
||||
|
||||
void // static
|
||||
nsPNGEncoder::ErrorCallback(png_structp png_ptr,
|
||||
png_const_charp error_msg)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// XXX: these messages are probably useful callers...
|
||||
// use nsIConsoleService?
|
||||
PR_fprintf(PR_STDERR, "PNG Encoder: %s\n", error_msg);;
|
||||
#endif
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
longjmp(png_ptr->jmpbuf, 1);
|
||||
#else
|
||||
png_longjmp(png_ptr, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// nsPNGEncoder::WriteCallback
|
||||
|
||||
void // static
|
||||
|
|
|
@ -81,7 +81,8 @@ protected:
|
|||
PRUint32 aPixelWidth, bool aUseTransparency);
|
||||
void StripAlpha(const PRUint8* aSrc, PRUint8* aDest,
|
||||
PRUint32 aPixelWidth);
|
||||
static void ErrorCallback(png_structp png_ptr, png_const_charp warning_msg);
|
||||
static void WarningCallback(png_structp png_ptr, png_const_charp warning_msg);
|
||||
static void ErrorCallback(png_structp png_ptr, png_const_charp error_msg);
|
||||
static void WriteCallback(png_structp png, png_bytep data, png_size_t size);
|
||||
void NotifyListener();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче