Skip to content

Commit a90ee07

Browse files
committed
FIX: crash when re-opening listening port multiple times
fixes: Oldes/Rebol-issues#2445
1 parent db71836 commit a90ee07

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/os/dev-net.c

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ static REBOOL Nonblocking_Mode(SOCKET sock)
260260
if (sock->handle) WSACancelAsyncRequest(sock->handle);
261261
#endif
262262
OS_Free(sock->net.host_info);
263+
sock->net.host_info = NULL;
263264
sock->socket = sock->length; // Restore TCP socket (see Lookup)
264265
}
265266

src/tests/units/crash-test.r3

+7
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ Rebol [
170170
--test-- "issue-441"
171171
;@@ https://github.com/Oldes/Rebol-issues/issues/441
172172
--assert unset? repeat n 1000000 [foreach a [1 2 3] []] ;- no crash
173+
174+
--test-- "issue-2445"
175+
;@@ https://github.com/Oldes/Rebol-issues/issues/2445
176+
--assert not error? try [p: open tcp://localhost:10000]
177+
loop 10 [--assert not error? try [close p open p]] ;- no crash
178+
--assert not error? try [close p]
179+
173180
===end-group===
174181

175182
~~~end-file~~~

0 commit comments

Comments
 (0)