ofproto-dpif: Avoid potential undefined behavior in type_run().
authorBen Pfaff <blp@nicira.com>
Tue, 18 Dec 2012 21:15:49 +0000 (13:15 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 18 Dec 2012 23:52:20 +0000 (15:52 -0800)
commit476cb42a5c638311b84a4015ae8058b536ff467f
tree18c674db1cec8e81c3d13e6388ad989e6c4f6f1a
parent1b567fb9afb3259646b7171eea38787d610a212c
ofproto-dpif: Avoid potential undefined behavior in type_run().

When HMAP_FOR_EACH completes, the value in the loop control variable is not
necessarily NULL.  It is NULL minus the offset of the hmap_node struct
member, which is nonnull if that offset is nonzero.  Currently,
'all_ofproto_dpifs_node' is the first member in struct ofproto_dpif, so
there is no real bug, but there would be if the struct were rearranged.

This commit heads off the problem by avoiding any assumption about the
loop control variable after HMAP_FOR_EACH.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif.c