From: Szymon Jastrzebski Date: Wed, 19 Jul 2017 08:26:56 +0000 (+0200) Subject: [Messaging] Adding checking return value of calloc X-Git-Tag: submit/tizen_3.0/20170721.122334~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b5569c9d1f6a78a4c6279d20b6bcabdfce1999f8;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Messaging] Adding checking return value of calloc SVACE detected problem with code DEREF_OF_NULL.RET.ALLOC. [Verification] Code compiles. Change-Id: Ibf604637e9f9d08e8c486a421afd94bbe6d6bddc Signed-off-by: Szymon Jastrzebski --- diff --git a/src/messaging/message.cc b/src/messaging/message.cc index 57703b13..14f37630 100755 --- a/src/messaging/message.cc +++ b/src/messaging/message.cc @@ -592,6 +592,10 @@ PlatformResult addSingleEmailAttachment(std::shared_ptr message, if (ret.IsError()) return ret; email_attachment_data_t* tmp = (email_attachment_data_t*)calloc(1, sizeof(email_attachment_data_t)); + if (nullptr == tmp) { + return LogAndCreateResult( + ErrorCode::UNKNOWN_ERR, "Unknown error while adding attachment."); + } tmp->attachment_name = strdup(att->getShortFileName().c_str()); tmp->attachment_path = strdup(std::string(dirPath + "/" + att->getShortFileName()).c_str());