Commit 92824a94 authored by Ian Craggs's avatar Ian Craggs

Fix some static analysis "problems"

Bug:375532
parent 0206989e
...@@ -662,34 +662,36 @@ int keysUnix(char *dirname, char ***keys, int *nkeys) ...@@ -662,34 +662,36 @@ int keysUnix(char *dirname, char ***keys, int *nkeys)
goto exit; goto exit;
} }
if (nfkeys != 0 ) if (nfkeys != 0)
{
fkeys = (char **)malloc(nfkeys * sizeof(char *)); fkeys = (char **)malloc(nfkeys * sizeof(char *));
/* copy the keys */ /* copy the keys */
if((dp = opendir(dirname)) != NULL) if((dp = opendir(dirname)) != NULL)
{
i = 0;
while((dir_entry = readdir(dp)) != NULL)
{ {
char* temp = malloc(strlen(dirname)+strlen(dir_entry->d_name)+2); i = 0;
while((dir_entry = readdir(dp)) != NULL)
sprintf(temp, "%s/%s", dirname, dir_entry->d_name);
if (lstat(temp, &stat_info) == 0 && S_ISREG(stat_info.st_mode))
{ {
fkeys[i] = malloc(strlen(dir_entry->d_name) + 1); char* temp = malloc(strlen(dirname)+strlen(dir_entry->d_name)+2);
strcpy(fkeys[i], dir_entry->d_name);
ptraux = strstr(fkeys[i], MESSAGE_FILENAME_EXTENSION); sprintf(temp, "%s/%s", dirname, dir_entry->d_name);
if ( ptraux != NULL ) if (lstat(temp, &stat_info) == 0 && S_ISREG(stat_info.st_mode))
*ptraux = '\0' ; {
i++; fkeys[i] = malloc(strlen(dir_entry->d_name) + 1);
strcpy(fkeys[i], dir_entry->d_name);
ptraux = strstr(fkeys[i], MESSAGE_FILENAME_EXTENSION);
if ( ptraux != NULL )
*ptraux = '\0' ;
i++;
}
free(temp);
} }
free(temp); closedir(dp);
} else
{
rc = MQTTCLIENT_PERSISTENCE_ERROR;
goto exit;
} }
closedir(dp);
} else
{
rc = MQTTCLIENT_PERSISTENCE_ERROR;
goto exit;
} }
*nkeys = nfkeys; *nkeys = nfkeys;
......
...@@ -616,6 +616,9 @@ int Socket_new(char* addr, int port, int* sock) ...@@ -616,6 +616,9 @@ int Socket_new(char* addr, int port, int* sock)
res = res->ai_next; res = res->ai_next;
} }
if (result == NULL)
rc = -1;
else
#if defined(AF_INET6) #if defined(AF_INET6)
if (result->ai_family == AF_INET6) if (result->ai_family == AF_INET6)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment