pmap: avoid depending on an uninitialised value.
It's possible for the first entry that this reads from /proc/*/smaps to start with a map_desc-less line like this: 7fa71b77d000-7fa71c288000 rw-p 00000000 00:00 0 in which case sscanf will only read up to inode, and it won't set c; the code below would then incorrectly discard the next ("Size:") line. (With GCC 4.9.0, this bug causes the "pmap extra extended output" test to fail for me.)
This commit is contained in:
parent
12f13f9fc2
commit
1d212457f2
1
pmap.c
1
pmap.c
@ -314,6 +314,7 @@ static void print_extended_maps (FILE *f)
|
|||||||
while (ret != NULL) {
|
while (ret != NULL) {
|
||||||
/* === READ MAPPING === */
|
/* === READ MAPPING === */
|
||||||
map_desc[0] = '\0';
|
map_desc[0] = '\0';
|
||||||
|
c = '\n';
|
||||||
nfields = sscanf(mapbuf,
|
nfields = sscanf(mapbuf,
|
||||||
"%"NUML"[0-9a-f]-%"NUML"[0-9a-f] "
|
"%"NUML"[0-9a-f]-%"NUML"[0-9a-f] "
|
||||||
"%"DETL"s %"NUML"[0-9a-f] "
|
"%"DETL"s %"NUML"[0-9a-f] "
|
||||||
|
Loading…
Reference in New Issue
Block a user