Re: Problems reading PNG from memory

John Bowler <[email protected]> Thu, 8 Sep 2022 12:17:12 -0700
Newsgroups gmane.comp.graphics.png.devel
Message-ID <CAP7U39_yBbhDOeL6PDSBnBL7COjMss_Dp0Xy-gS9XXLjYjzRiQ@mail.gmail.com>
On Thu, Sep 8, 2022 at 11:46 AM John Bowler <
[email protected]> wrote:

> This should work:
>>
>
> png_image image;
>> image.version = PNG_IMAGE_VERSION;
>> png_image_beging_read_from_memory(&image, *image_data*, sizeof
>> *image_data*);
>> if (PNG_IMAGE_FAILED(image))
>>    fprintf(stderr, "PNG read failed: '%s'\n", image.message);
>
>
A correction, the opaque pointer must be set to NULL as well:


> png_image image;
>
*image.opaque = 0;*

image.version = PNG_IMAGE_VERSION;
>
>> png_image_beging_read_from_memory(&image, *image_data*, sizeof
> *image_data*);
>
>> if (PNG_IMAGE_FAILED(image))
>    fprintf(stderr, "PNG read failed: '%s'\n", image.message);
>

If the opaque pointer isn't NULL on entry to png_image_begin_read_ the call
will fail and, I think, crash (inside png_image_error).

_______________________________________________
png-mng-implement mailing list
png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/png-mng-implement