One thing to note is that when I only apply the first commit, NsiAllocateAndGetTable() sometimes fails to allocate the tables. This results in both the NsiAllocateAndGetTable() and GetExtendedTcpTable() calls to fail in test_tcp_tables() which is quickly followed by a crash:
nsi.c:872: Test failed: AF_INET: 8: got 14 /* ERROR_OUTOFMEMORY */ nsi.c:881: Test failed: AF_INET: 8: got 122 /* ERROR_INSUFFICIENT_BUFFER */ wine: Unhandled page fault on read access to 0116B1F4 at address 00401336 (thread 0024), starting debugger... [...] Backtrace: =>0 0x00401336 test_tcp_tables+0x317(family=<internal error>, table_type=<internal error>) [Z:\home\fgouget\wine\wine-gitlab\dlls\nsi\tests\nsi .c:901] in nsi_test (0x0064fdb8)
That makes sense since dyn_tbl was left uninitialized by NsiAllocateAndGetTable().
So one could say that the test is buggy and should take this case into account. Or one can consider that it is up to NsiAllocateAndGetTable() to not fail to allocate the table over trivial issues, which seems to be the whole point of the 5 attempts loop. So that's why I also included the second patch which completely eliminates these failures on my box.