X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=common%2Ftr_name.c;fp=common%2Ftr_name.c;h=0e15595daa2ae15f735b92288ac1038bb15f739b;hb=90d9e3659318270c28a7ea8bf018e07512901a06;hp=00757d440ecf22d35d73521b1092d5e8c76bd46c;hpb=0a3175f17c1ddcf19eef3683cd56081be60d2e8b;p=trust_router.git diff --git a/common/tr_name.c b/common/tr_name.c index 00757d4..0e15595 100644 --- a/common/tr_name.c +++ b/common/tr_name.c @@ -64,14 +64,17 @@ TR_NAME *tr_dup_name (TR_NAME *from) { TR_NAME *to; - if (to = malloc(sizeof(TR_NAME))) { + if (!from) { + return NULL; + } + + if (NULL != (to = malloc(sizeof(TR_NAME)))) { to->len = from->len; - if (to->buf = malloc(to->len+1)) { + if (NULL != (to->buf = malloc(to->len+1))) { strncpy(to->buf, from->buf, from->len); to->buf[to->len] = 0; /* NULL terminate for debugging printf()s */ } } - return to; }