Commit ceb14b1c authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: calloc was misused. Memory corruption.

This dates back to the original copying over from ptp-noposix:

  89a46c6d time-wrs/wrs-socket.c: implementation of net functions for wrs arch

(but the bug was not in ptp-noposix).

It is exposed by the newer compiler (well, library) we are using.
But a calloc of 0 bytes should return NULL, to ensure it's not used...
Documentation disagrees:

       If size is 0, then malloc() returns either NULL, or a unique
       pointer value that can later be successfully passed to free().
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
parent 097342ae
......@@ -643,7 +643,7 @@ static int wrs_net_init(struct pp_instance *ppi)
/* Only one wrs_socket is created for each pp_instance, because
* wrs_socket is related to the interface and not to the pp_channel */
struct wrs_socket *s = calloc(0, sizeof(struct wrs_socket));
struct wrs_socket *s = calloc(1, sizeof(struct wrs_socket));
if (!s)
return -1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment