Fix potential invalid read in shift_left()
commit38e8e7d1527cab1d7c9d5cc8030c940d4e2485fb
authorJonas Fonseca <jonas.fonseca@gmail.com>
Tue, 9 Jun 2015 00:30:38 +0000 (8 20:30 -0400)
committerJonas Fonseca <jonas.fonseca@gmail.com>
Tue, 9 Jun 2015 00:30:38 +0000 (8 20:30 -0400)
tree66c5af6a53d72220e420daa9078c066afc694ad3
parentf0c1f17e7a824dd779028032a5c9240a75218bde
Fix potential invalid read in shift_left()

The second call to shift_left() in graph_generate_symbols() passes as
the index `pos + 1` where `pos` is bounded by `row->size` and will
therefore be an invalid for the last index. The fix is to check the
bounds of `pos + 1` and only conditionally invoke shift_left().

The stacktrace as reported in issue #402:

    #0 0x00000c47bba3a095 in shift_left (row=0xc4a76750c50, prev_row=0xc4a76750c70, pos=64) at src/graph-v2.c:493
    493 if (!graph_column_has_commit(&row->columns[pos]))
    (gdb) bt
    #0 0x00000c47bba3a095 in shift_left (row=0xc4a76750c50, prev_row=0xc4a76750c70, pos=64) at src/graph-v2.c:493
    #1 0x00000c47bba3aad7 in graph_generate_symbols (graph=0xc4a76750c00, canvas=0xc4a5c144450) at src/graph-v2.c:671
    #2 0x00000c47bba3ac86 in graph_render_parents (graph_ref=0xc4a76750c00, canvas=0xc4a5c144450) at src/graph-v2.c:701
src/graph-v2.c