diff options
author | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-23 20:33:01 +0000 |
---|---|---|
committer | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-23 20:33:01 +0000 |
commit | ba8b9fc8d511abd4198df1fb00e85fc35cde714b (patch) | |
tree | 71f71c4ba2312fc27cef51a682d5894110e24996 /channels/chan_zap.c | |
parent | dfca19960211143fcbb595725930ab4649c0a450 (diff) |
Check return value of malloc before dereferencing ptr in chan_zap.c
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4066 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_zap.c')
-rwxr-xr-x | channels/chan_zap.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c index ad9ba471e..7389bfcfe 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -3495,15 +3495,19 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast) if (p->zaptrcallerid) { if (!p->origcid_num) { p->origcid_num = malloc(strlen(p->cid_num) + 1); - strncpy(p->origcid_num, p->cid_num, strlen(p->cid_num)); /* safe */ - /* make sure p->origcallerid is terminated */ - p->origcid_num[strlen(p->cid_num)] = '\0'; + if (p->origcid_num) { + strncpy(p->origcid_num, p->cid_num, strlen(p->cid_num)); /* safe */ + /* make sure p->origcallerid is terminated */ + p->origcid_num[strlen(p->cid_num)] = '\0'; + } } if (!p->origcid_name) { p->origcid_name = malloc(strlen(p->cid_name) + 1); - strncpy(p->origcid_name, p->cid_name, strlen(p->cid_name)); /* safe */ - /* make sure p->origcallerid is terminated */ - p->origcid_name[strlen(p->cid_name)] = '\0'; + if (p->origcid_name) { + strncpy(p->origcid_name, p->cid_name, strlen(p->cid_name)); /* safe */ + /* make sure p->origcallerid is terminated */ + p->origcid_name[strlen(p->cid_name)] = '\0'; + } } strncpy(p->cid_num, cid_num, sizeof(p->cid_num) -1); strncpy(p->cid_name, cid_name, sizeof(p->cid_name) -1); |