From 8e3bebc736c224db4d7fc81ab9fa841c7015318a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 30 Dec 2019 14:18:35 -0800 Subject: fixes #1075 WebSocket heap use after free This also introduces a new atomic boolean type, so we can use that to trigger whether we've added the HTTP handler or not. --- src/platform/windows/win_thread.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/platform/windows/win_thread.c') diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index 076da9e4..763dcf7f 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -131,6 +131,30 @@ nni_atomic_flag_reset(nni_atomic_flag *f) InterlockedExchange(&f->f, 0); } +void +nni_atomic_set_bool(nni_atomic_bool *v, bool b) +{ + InterlockedExchange(&v->v, (LONG) b); +} + +bool +nni_atomic_get_bool(nni_atomic_bool *v) +{ + return ((bool) InterlockedAdd(&v->v, 0)); +} + +bool +nni_atomic_swap_bool(nni_atomic_bool *v, bool b) +{ + return ((bool) InterlockedExchange(&v->v, (LONG) b)); +} + +void +nni_atomic_init_bool(nni_atomic_bool *v) +{ + InterlockedExchange(&v->v, 0); +} + void nni_atomic_add64(nni_atomic_u64 *v, uint64_t bump) { -- cgit v1.2.3-70-g09d2