davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.01k stars 250 forks source link

06-onion.c: Fix value of 'sizeof' when allocating 'pthread_t' array with 'malloc' #299

Closed Bogdanisar closed 2 years ago

Bogdanisar commented 2 years ago

Hello, I suspect that the project uses an improper sizeof value when calling malloc inside the tests file. We are creating an array of pthread_t so we should call malloc with sizeof(pthread_t), but we use the size of the pointer instead.

The execution might run fine because pthread_t and pthread_t * can have the same size (both are 8 bytes on my machine), but that is not necessarily true.

I think that we should change it.

davidmoreno commented 2 years ago

Thanks!