Commit a6b5acb9 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Initialize png comment hash after setjmp() to avoid clobbering it

parent e91a10ec
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

gib_hash *feh_png_read_comments(char *file)
{
	gib_hash *hash = NULL;

	FILE *fp;
	int i, sig_bytes, comments = 0;

@@ -45,31 +43,31 @@ gib_hash *feh_png_read_comments(char *file)
	png_textp text_ptr;

	if (!(fp = fopen(file, "rb")))
		return hash;
		return NULL;

	if (!(sig_bytes = feh_png_file_is_png(fp))) {
		fclose(fp);
		return hash;
		return NULL;
	}

	/* initialize data structures */
	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	if (!png_ptr) {
		fclose(fp);
		return hash;
		return NULL;
	}

	info_ptr = png_create_info_struct(png_ptr);
	if (!info_ptr) {
		png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
		fclose(fp);
		return hash;
		return NULL;
	}

	if (setjmp(png_jmpbuf(png_ptr))) {
		png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
		fclose(fp);
		return hash;
		return NULL;
	}

	/* initialize reading */
@@ -78,6 +76,8 @@ gib_hash *feh_png_read_comments(char *file)

	png_read_info(png_ptr, info_ptr);

	gib_hash *hash = NULL;

#ifdef PNG_TEXT_SUPPORTED
	png_get_text(png_ptr, info_ptr, &text_ptr, &comments);
	if (comments > 0) {