Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
packet: initialize all fields of pktbuf_t
  • Loading branch information
perexg committed Sep 23, 2015
1 parent c99e7c1 commit 4bfd50d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/packet.c
Expand Up @@ -187,11 +187,14 @@ pktbuf_alloc(const void *data, size_t size)
pktbuf_t *pb = malloc(sizeof(pktbuf_t));
pb->pb_refcount = 1;
pb->pb_size = size;
pb->pb_err = 0;

if(size > 0) {
pb->pb_data = malloc(size);
if(data != NULL)
memcpy(pb->pb_data, data, size);
} else {
pb->pb_data = NULL;
}
return pb;
}
Expand Down

0 comments on commit 4bfd50d

Please sign in to comment.