diff options
author | Robbie Shade <rjshade@google.com> | 2017-03-08 12:54:28 -0500 |
---|---|---|
committer | Robbie Shade <rjshade@google.com> | 2017-03-08 12:54:28 -0500 |
commit | 69709e2819f5eeeb47a16f7ed964dd1196b94ff0 (patch) | |
tree | 5afca8650b1b7bca7ca1f56c40f00e432d3b5c24 /src | |
parent | efe7572c72343cdaa865c1e86d29e98ed13b704b (diff) |
Fix flaky use-after-free in udp_server
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/iomgr/udp_server.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c index 2a1c8d39fa..d1bcd89af1 100644 --- a/src/core/lib/iomgr/udp_server.c +++ b/src/core/lib/iomgr/udp_server.c @@ -485,7 +485,11 @@ void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *s, grpc_schedule_on_exec_ctx); grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure); - s->active_ports++; + /* Registered for both read and write callbacks: increment active_ports + * twice to account for this, and delay free-ing of memory until both + * on_read and on_write have fired. */ + s->active_ports += 2; + sp = sp->next; } |