for (uint32_t i = 0; i < arrayLength; i++)
{
uint16_t *port = (uint16_t *)u_arraylist_get(portList, i);
+ if (!port)
+ {
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "Failed to get port from sender info !");
+ u_arraylist_destroy(portList);
+ return;
+ }
+
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "port : %X", *port);
if (CA_STATUS_OK == CALEGetSenderInfo(address, *port,
if (!strncmp(info->remoteEndpoint->addr, leAddress, addrLength))
{
uint16_t *port = (uint16_t *)OICMalloc(sizeof(uint16_t));
+ if (!port)
+ {
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "memory allocation failed!");
+ return CA_MEMORY_ALLOC_FAILED;
+ }
*port = info->remoteEndpoint->port;
u_arraylist_add(portList, (void *)port);
}
static bool CASendNetlinkMessage(int netlinkFd, const void* data, size_t len)
{
- ssize_t sentByteCount = TEMP_FAILURE_RETRY(send(netlinkFd, data, len, 0));
+ ssize_t sentByteCount = 0;
+ sentByteCount = TEMP_FAILURE_RETRY(send(netlinkFd, data, len, 0));
return (sentByteCount == (ssize_t)(len));
}
void CAFreeIfAddrs(struct ifaddrs *ifa)
{
- struct ifaddrs *cur;
+ struct ifaddrs *cur = NULL;
while (ifa)
{
cur = ifa;
{
case IFA_ADDRESS:
ss = (struct sockaddr_storage*)OICCalloc(1, sizeof(struct sockaddr_storage));
+ if (!ss)
+ {
+ OIC_LOG(ERROR, TAG, "Memory allocation failed!");
+ return NULL;
+ }
ss->ss_family = ifaddrmsgData-> ifa_family;
if (ifaddrmsgData-> ifa_family == AF_INET)
return CA_SOCKET_OPERATION_FAILED;
}
return CA_STATUS_OK;
-}
\ No newline at end of file
+}
size_t mtDim[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **mediaType = (char **)OICMalloc(sizeof(char *) * 1);
+ if (!mediaType)
+ {
+ OIC_LOG(ERROR, TAG, "Memory allocation failed!");
+
+ for(uint8_t i = 0; i < nPubResHandles; i++)
+ {
+ OCRepPayloadDestroy(linkArr[i]);
+ }
+ OICFree(linkArr);
+ OCRepPayloadDestroy(rdPayload);
+ return OC_STACK_NO_MEMORY;
+ }
+
mediaType[0] = OICStrdup(DEFAULT_MESSAGE_TYPE);
OCRepPayloadSetStringArrayAsOwner(link, OC_RSRVD_MEDIA_TYPE, mediaType,
mtDim);
{
OCRepPayload *rdPayload = (OCRepPayload *) response->payload;
OCRepPayload **links = NULL;
- size_t dimensions[MAX_REP_ARRAY_DEPTH];
+ size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
if (OCRepPayloadGetPropObjectArray(rdPayload, OC_RSRVD_LINKS,
&links, dimensions))
{