diff options
author | Yang Gao <yangg@google.com> | 2017-03-08 17:13:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 17:13:31 -0800 |
commit | 2e0a82f14db01fc6adc4df207f76deb9263f4fc7 (patch) | |
tree | 991a6a43e6a6ab592ede9051c997c8260d8662bb /src | |
parent | c35a5b0e74b036acaf9129118fe449c72bb5f696 (diff) | |
parent | 69709e2819f5eeeb47a16f7ed964dd1196b94ff0 (diff) |
Merge pull request #10040 from rjshade/udp_use_after_free
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; } |