summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@daimi.au.dk>2010-11-09 08:29:03 -0500
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>2011-06-29 02:48:21 -0400
commit6e187f04443b62e2085d837457b902ddcc2c1459 (patch)
treec5b14e55f9f99493560175857e63cf8f8e31b208
parente061ff84c185a74c658cae0f582a30a543fb155a (diff)
Fix bug in move to front
-rw-r--r--tracker.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/tracker.c b/tracker.c
index 193cddf..9297ea0 100644
--- a/tracker.c
+++ b/tracker.c
@@ -417,15 +417,19 @@ process_locate_map (process_t *process, gulong addr)
{
map_t *map = &g_array_index (maps, map_t, i);
- if (addr >= map->start && addr < map->end && i > 0)
+ if (addr >= map->start && addr < map->end)
{
- map_t tmp = *map;
-
- memmove (&(g_array_index (maps, map_t, 1)),
- &(g_array_index (maps, map_t, 0)),
- i * sizeof (map_t));
-
- g_array_index (maps, map_t, 0) = tmp;
+ if (i > 0)
+ {
+ /* Move to front */
+ map_t tmp = *map;
+
+ memmove (&(g_array_index (maps, map_t, 1)),
+ &(g_array_index (maps, map_t, 0)),
+ i * sizeof (map_t));
+
+ g_array_index (maps, map_t, 0) = tmp;
+ }
return &g_array_index (maps, map_t, 0);
}