Fraunhofer-IIS / libjapi

libjapi is a universal JSON to C API library. It receives newline-delimited JSON (NDJSON) messages via TCP and calls registered C functions. A JSON response is returned for each request. Furthermore, it is also possible to create push services, which asynchronously push JSON messages to the clients subscribed to them.
MIT License
3 stars 1 forks source link

Valgrind: Invalid read of size 4 after client disconnect #37

Closed fraunhofer-iis-bot closed 1 year ago

fraunhofer-iis-bot commented 2 years ago

In GitLab by @Michael-M-Baron on Sep 13, 2021, 11:35

The problem occurs in the main loop of the japi server while processing the received lines. After a client is disconnected, the client object gets cleaned and freed with japi_remove_client(ctx,client->socket); At the end of the loop, the client object is accessed again in the loop condition, but the memory has already been freed, what produces an error in valgrind.

Japi.c: Line 538

fraunhofer-iis-bot commented 2 years ago

In GitLab by @Michael-M-Baron on Sep 13, 2021, 11:35

created merge request !58 to address this issue

fraunhofer-iis-bot commented 2 years ago

In GitLab by @cstender on Sep 28, 2021, 16:32

Thanks a lot for spotting, debugging and fixing the issue!