Skip to content
Snippets Groups Projects
Commit 2efc6de7 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Merge branch 'prevent_undefined_behavior' into 'master'

prevent undefined behavior

See merge request !10
parents 56a57c68 ce27b779
No related branches found
Tags v0.08
1 merge request!10prevent undefined behavior
......@@ -288,11 +288,13 @@ int rmap_set_reply_path(struct rmap_pkt *pkt, const uint8_t *rpath, uint8_t len)
pkt->rpath_len = len;
pkt->rpath = (uint8_t *) malloc(pkt->rpath_len);
if (!pkt->rpath)
return -1;
if (len) {
pkt->rpath = (uint8_t *) malloc(pkt->rpath_len);
if (!pkt->rpath)
return -1;
memcpy(pkt->rpath, rpath, pkt->rpath_len);
memcpy(pkt->rpath, rpath, pkt->rpath_len);
}
/* number of 32 bit words needed to contain the path */
pkt->ri.reply_addr_len = len >> 2;
......@@ -326,6 +328,9 @@ int rmap_set_dest_path(struct rmap_pkt *pkt, const uint8_t *path, uint8_t len)
pkt->path_len = len;
if (!len)
return 0;
pkt->path = (uint8_t *) malloc(pkt->path_len);
if (!pkt->path)
return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment