summaryrefslogtreecommitdiff
path: root/src/feh_png.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-09-16 11:15:27 +0200
committerDaniel Friesel <derf@finalrewind.org>2017-09-16 11:15:27 +0200
commita6b5acb94f1d851c738f23a86020783d77173b4d (patch)
treeebda679a4d89ccefd61b0c64cf27e65f2625fc13 /src/feh_png.c
parente91a10ecb2e1f7c237e77e47936932ce14fbec32 (diff)
Initialize png comment hash after setjmp() to avoid clobbering it
Diffstat (limited to 'src/feh_png.c')
-rw-r--r--src/feh_png.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/feh_png.c b/src/feh_png.c
index ff73f56..d27df01 100644
--- a/src/feh_png.c
+++ b/src/feh_png.c
@@ -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) {