openziti / ziti-tunnel-sdk-c

Apache License 2.0
42 stars 15 forks source link

advance map iterators with model_map_it_remove when removing map items #822

Closed scareything closed 3 months ago

scareything commented 3 months ago

Using a map iterator after removing the last item from the map can lead to invalid reads.

==1994639== Invalid read of size 8
==1994639==    at 0x159779: model_map_it_next (model_collections.c:245)
==1994639==    by 0x16FB6C: ziti_dns_deregister_intercept (ziti_dns.c:378)
==1994639==    by 0x163231: stop_intercept (ziti_tunnel_cbs.c:503)
==1994639==    by 0x163231: ziti_sdk_c_on_service (ziti_tunnel_cbs.c:571)
==1994639==    by 0x167948: on_service (ziti_tunnel_ctrl.c:725)
==1994639==    by 0x167DF7: on_ziti_event (ziti_tunnel_ctrl.c:800)