3 ms·
You shouldn't allocate heap space for a pointer in blocking_pipe_read. Also, it looks like you're leaking it in the else branch. Just allocate a pointer on th
by clarry 12y ago
You shouldn't allocate heap space for a pointer in blocking_pipe_read. Also, it looks like you're leaking it in the else branch.
Just allocate a pointer on the stack, read into it, and then assign the value into the provided space:
void *msg_ptr;
read(..., &msg_ptr, sizeof msg_ptr);
*data = msg_ptr;