From 84dc29b929ca9b32c5898bf58ea7e70e4651952e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 11 Sep 2016 21:19:16 +0200 Subject: [PATCH 1/2] Make sure shifted value is unsigned --- src/peep/staff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peep/staff.c b/src/peep/staff.c index 8089a10eda..61a31ac64c 100644 --- a/src/peep/staff.c +++ b/src/peep/staff.c @@ -610,7 +610,7 @@ bool staff_is_patrol_area_set(int staffIndex, int x, int y) int peepOffset = staffIndex * 128; int offset = (x | y) >> 5; int bitIndex = (x | y) & 0x1F; - return gStaffPatrolAreas[peepOffset + offset] & (1 << bitIndex); + return gStaffPatrolAreas[peepOffset + offset] & (((uint32)1) << bitIndex); } void staff_set_patrol_area(int staffIndex, int x, int y, bool value) From f6daea7cef6fb2d44779477d97b32838bc6c8bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 11 Sep 2016 21:20:03 +0200 Subject: [PATCH 2/2] Guard against passing NULL to qsort() --- src/windows/server_list.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/windows/server_list.c b/src/windows/server_list.c index 596bc3cc54..017d66a5ff 100644 --- a/src/windows/server_list.c +++ b/src/windows/server_list.c @@ -695,6 +695,9 @@ static int server_compare(const void *a, const void *b) static void sort_servers() { + if (_serverEntries == NULL) { + return; + } qsort(_serverEntries, _numServerEntries, sizeof(server_entry), server_compare); }