mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 19:42:26 +00:00
[550/906] GstGLOverlay: fix libPNG complaining about unsigned integer being out of range
This commit is contained in:
parent
b54f031278
commit
b34d014918
1 changed files with 15 additions and 11 deletions
|
@ -678,7 +678,6 @@ gst_gl_overlay_load_png (GstGLFilter * filter)
|
|||
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
guint sig_read = 0;
|
||||
png_uint_32 width = 0;
|
||||
png_uint_32 height = 0;
|
||||
gint bit_depth = 0;
|
||||
|
@ -689,22 +688,27 @@ gst_gl_overlay_load_png (GstGLFilter * filter)
|
|||
guchar **rows = NULL;
|
||||
gint filler;
|
||||
png_byte magic[8];
|
||||
size_t read;
|
||||
gint n_read;
|
||||
|
||||
if (!filter->display)
|
||||
return 1;
|
||||
if ((fp = fopen (overlay->location, "rb")) == NULL)
|
||||
LOAD_ERROR ("file not found");
|
||||
read = fread (magic, 1, sizeof (magic), fp);
|
||||
if (read == 0 || !png_check_sig (magic, sizeof (magic))) {
|
||||
fclose (fp);
|
||||
return 0;
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
if ((fp = fopen (overlay->location, "rb")) == NULL)
|
||||
LOAD_ERROR ("file not found");
|
||||
|
||||
/* Read magic number */
|
||||
n_read = fread (magic, 1, sizeof (magic), fp);
|
||||
if (n_read != sizeof (magic)) {
|
||||
fclose (fp);
|
||||
LOAD_ERROR ("can't read PNG magic number");
|
||||
}
|
||||
|
||||
/* Check for valid magic number */
|
||||
if (png_sig_cmp (magic, 0, sizeof (magic))) {
|
||||
fclose (fp);
|
||||
LOAD_ERROR ("not a valid PNG image");
|
||||
}
|
||||
|
||||
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
|
||||
if (png_ptr == NULL) {
|
||||
|
@ -723,7 +727,7 @@ gst_gl_overlay_load_png (GstGLFilter * filter)
|
|||
|
||||
png_init_io (png_ptr, fp);
|
||||
|
||||
png_set_sig_bytes (png_ptr, sig_read);
|
||||
png_set_sig_bytes (png_ptr, sizeof (magic));
|
||||
|
||||
png_read_info (png_ptr, info_ptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue