icoutils/0017-icotool-Note-that-we-are-ignoring-errors-in-palette_.patch
Richard W.M. Jones 86a1ed311e Add a series of upstream patches to enable compiler warnings and
fix multiple issues.

Revert one of the checks which breaks processing of PE binaries.

Removed the 'Group' line, not needed with modern Fedora/RPM.
2017-03-10 12:18:04 +00:00

41 lines
1.3 KiB
Diff

From b05980b0dbf470f7b2d952de36336119ae7dac12 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 9 Mar 2017 14:24:22 +0000
Subject: [PATCH 17/26] icotool: Note that we are ignoring errors in
palette_lookup function.
Previously palette_lookup could return -1 for error. This was
assigned to uint32_t (thus provoking a warning from GCC), but the
error condition was never checked so 0xffffffff would end up being
assigned to the output icon.
This change just makes what we are doing here more explicit, but does
not change the semantics.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
icotool/palette.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/icotool/palette.c b/icotool/palette.c
index a2f4f3d..8e8c57f 100644
--- a/icotool/palette.c
+++ b/icotool/palette.c
@@ -125,7 +125,12 @@ palette_lookup(Palette *palette, uint8_t r, uint8_t g, uint8_t b)
{
PaletteColor color = { r, g, b, 0 };
PaletteColor *real_color = hmap_get(palette->map, &color);
- return (real_color != NULL ? real_color->index : -1);
+ /* The caller doesn't handle this as an error, but simply
+ * assigns 0xffffffff as a colour in the output.
+ */
+ if (real_color == NULL)
+ return (uint32_t)-1;
+ return real_color->index;
}
uint32_t
--
2.10.2