lammertb / libhttp

Multi platform HTTP and HTTPS library
MIT License
957 stars 131 forks source link

XX_httplib_worker_thread() frees memory it doesn't own #34

Closed lammertb closed 7 years ago

lammertb commented 7 years ago

The function XX_httplib_worker_thread() frees memory which was passed to it as parameter and which it doesn't own. This assumes that the pointer is valid and was allocated before and not static, and that the memory structure is not complex with other memory blocks to be freed. This may be legitimate or not, but should be investigated.

lammertb commented 7 years ago

This seems to be planned behaviour. The overall array with worker thread IDs is allocated, stored and deleted globally. But no function keeps track of all individual members of this array. When a worker thread is created, the responsibility to free the memory is passed to the worker thread which deallocates the memory at the end of the execution. Only if the initialization of the worker thread fails, the calling routine performs the cleanup.