diff options
author | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2010-11-09 08:29:03 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <sandmann@daimi.au.dk> | 2011-06-29 02:48:21 -0400 |
commit | 6e187f04443b62e2085d837457b902ddcc2c1459 (patch) | |
tree | c5b14e55f9f99493560175857e63cf8f8e31b208 | |
parent | e061ff84c185a74c658cae0f582a30a543fb155a (diff) |
Fix bug in move to front
-rw-r--r-- | tracker.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -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); } |