From 28fa0d23c16fd5747735263c7b6de604e599b22b Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Mon, 21 Dec 2015 11:29:03 +0000 Subject: [PATCH] Reverse order of tests in png_zlib_compress_validate Undefined behaviour sanitizer currently fires for this test with an error about member access within null pointer to struct; put the check that relies on pz->list being non-NULL second. --- pngwutil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pngwutil.c b/pngwutil.c index 231e5d32d..2674b9fb8 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -482,10 +482,10 @@ png_zlib_compress_validate(png_zlib_compressp pz, int in_use) if (pz->overflow == 0U && pz->len == 0U && pz->start == 0U) /* empty */ { - affirm((pz->end == &pz->list->next && pz->zs.next_out == pz->list->output - && pz->zs.avail_out == o_size) || - (pz->end == &pz->list && pz->zs.next_out == NULL - && pz->zs.avail_out == 0U)); + affirm((pz->end == &pz->list && pz->zs.next_out == NULL + && pz->zs.avail_out == 0U) || + (pz->end == &pz->list->next && pz->zs.next_out == pz->list->output + && pz->zs.avail_out == o_size)); } else /* not empty */