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)
goto exit;
}
if (nfkeys != 0 )
if (nfkeys != 0)
{
fkeys = (char **)malloc(nfkeys * sizeof(char *));
/* copy the keys */
if((dp = opendir(dirname)) != NULL)
{
i = 0;
while((dir_entry = readdir(dp)) != NULL)
/* copy the keys */
if((dp = opendir(dirname)) != NULL)
{
char* temp = malloc(strlen(dirname)+strlen(dir_entry->d_name)+2);
sprintf(temp, "%s/%s", dirname, dir_entry->d_name);
if (lstat(temp, &stat_info) == 0 && S_ISREG(stat_info.st_mode))
i = 0;
while((dir_entry = readdir(dp)) != NULL)
{
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++;
char* temp = malloc(strlen(dirname)+strlen(dir_entry->d_name)+2);
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);
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;
......
......@@ -616,6 +616,9 @@ int Socket_new(char* addr, int port, int* sock)
res = res->ai_next;
}
if (result == NULL)
rc = -1;
else
#if defined(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