summaryrefslogtreecommitdiffstats
path: root/libdwfl/dwfl_module.c
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2006-07-11 22:32:28 +0000
committerUlrich Drepper <[email protected]>2006-07-11 22:32:28 +0000
commitc87b6e76285a0f6da401a5de2aa7b096b9ec731a (patch)
treece12466219d5073f42779588295df091c6c274dc /libdwfl/dwfl_module.c
parent28ed895fdc303b2a793506bb1fcdd35d5fd14e70 (diff)
Fix overflow in compare_modules return value.
Diffstat (limited to 'libdwfl/dwfl_module.c')
-rw-r--r--libdwfl/dwfl_module.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
index 022bfea1..6f3aa849 100644
--- a/libdwfl/dwfl_module.c
+++ b/libdwfl/dwfl_module.c
@@ -1,5 +1,5 @@
/* Maintenance of module list in libdwfl.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -161,6 +161,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
}
INTDEF (dwfl_report_module)
+
static int
compare_modules (const void *a, const void *b)
{
@@ -170,7 +171,13 @@ compare_modules (const void *a, const void *b)
return -1;
if (m2 == NULL)
return 1;
- return (GElf_Sxword) (m1->low_addr - m2->low_addr);
+
+ GElf_Sxword diff = m1->low_addr - m2->low_addr;
+ if (diff < 0)
+ return -1;
+ if (diff > 0)
+ return 1;
+ return 0;
}