diff options
author | Ben Pfaff <blp@nicira.com> | 2012-01-13 13:30:42 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-01-13 15:11:01 -0800 |
commit | 78945f19d7147096294cb8557f3eafbb809017a3 (patch) | |
tree | 8755dc62f7b957c8b84238a22e1b9fd750f909a0 /lib/netdev-dummy.c | |
parent | d0a8c2e057fe2c7e622a906e67f2811d0186a2d6 (diff) |
netdev-dummy: Fix use-after-free error.
Found by valgrind.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netdev-dummy.c')
-rw-r--r-- | lib/netdev-dummy.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index 94dea765..d94af415 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011 Nicira Networks. + * Copyright (c) 2010, 2011, 2012 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,6 +156,7 @@ netdev_dummy_recv(struct netdev *netdev_, void *buffer, size_t size) { struct netdev_dummy *netdev = netdev_dummy_cast(netdev_); struct ofpbuf *packet; + size_t packet_size; if (list_is_empty(&netdev->recv_queue)) { return -EAGAIN; @@ -165,11 +166,12 @@ netdev_dummy_recv(struct netdev *netdev_, void *buffer, size_t size) if (packet->size > size) { return -EMSGSIZE; } + packet_size = packet->size; memcpy(buffer, packet->data, packet->size); ofpbuf_delete(packet); - return packet->size; + return packet_size; } static void |