diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-30 14:18:35 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-30 14:39:50 -0800 |
| commit | 8e3bebc736c224db4d7fc81ab9fa841c7015318a (patch) | |
| tree | 0efb68886652936a6fa79fb290268a683cd3564f /src/platform/windows | |
| parent | 3890f856068542c6ddb7b498a2e313b026450bd2 (diff) | |
| download | nng-8e3bebc736c224db4d7fc81ab9fa841c7015318a.tar.gz nng-8e3bebc736c224db4d7fc81ab9fa841c7015318a.tar.bz2 nng-8e3bebc736c224db4d7fc81ab9fa841c7015318a.zip | |
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.
Diffstat (limited to 'src/platform/windows')
| -rw-r--r-- | src/platform/windows/win_impl.h | 4 | ||||
| -rw-r--r-- | src/platform/windows/win_thread.c | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h index cd15804a..befcd185 100644 --- a/src/platform/windows/win_impl.h +++ b/src/platform/windows/win_impl.h @@ -50,6 +50,10 @@ struct nni_atomic_flag { unsigned f; }; +struct nni_atomic_bool { + LONG v; +}; + struct nni_atomic_u64 { LONGLONG v; }; 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 @@ -132,6 +132,30 @@ nni_atomic_flag_reset(nni_atomic_flag *f) } 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) { InterlockedAddNoFence64(&v->v, (LONGLONG) bump); |
