[C][Client][Clang Static Analyzer] Fix uninitialized argument value (#7305)

This commit is contained in:
Hui Yu
2020-08-28 09:44:55 +08:00
committed by GitHub
parent 26c17c5774
commit 08fe44c764
4 changed files with 159 additions and 57 deletions

View File

@@ -76,7 +76,7 @@ PetAPI_addPet(apiClient_t *apiClient, pet_t * body )
// Body Param
cJSON *localVarSingleItemJSON_body;
cJSON *localVarSingleItemJSON_body = NULL;
if (body != NULL)
{
//string
@@ -111,7 +111,10 @@ end:
list_free(localVarContentType);
free(localVarPath);
cJSON_Delete(localVarSingleItemJSON_body);
if (localVarSingleItemJSON_body) {
cJSON_Delete(localVarSingleItemJSON_body);
localVarSingleItemJSON_body = NULL;
}
free(localVarBodyParameters);
}
@@ -151,7 +154,7 @@ PetAPI_deletePet(apiClient_t *apiClient, long petId , char * api_key )
// header parameters
char *keyHeader_api_key;
char *keyHeader_api_key = NULL;
char * valueHeader_api_key;
keyValuePair_t *keyPairHeader_api_key = 0;
if (api_key) {
@@ -188,7 +191,10 @@ end:
free(localVarPath);
free(localVarToReplace_petId);
free(keyHeader_api_key);
if (keyHeader_api_key) {
free(keyHeader_api_key);
keyHeader_api_key = NULL;
}
free(valueHeader_api_key);
free(keyPairHeader_api_key);
@@ -463,7 +469,7 @@ PetAPI_updatePet(apiClient_t *apiClient, pet_t * body )
// Body Param
cJSON *localVarSingleItemJSON_body;
cJSON *localVarSingleItemJSON_body = NULL;
if (body != NULL)
{
//string
@@ -504,7 +510,10 @@ end:
list_free(localVarContentType);
free(localVarPath);
cJSON_Delete(localVarSingleItemJSON_body);
if (localVarSingleItemJSON_body) {
cJSON_Delete(localVarSingleItemJSON_body);
localVarSingleItemJSON_body = NULL;
}
free(localVarBodyParameters);
}
@@ -544,7 +553,7 @@ PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId , char * name , char
// form parameters
char *keyForm_name;
char *keyForm_name = NULL;
char * valueForm_name;
keyValuePair_t *keyPairForm_name = 0;
if (name != NULL)
@@ -556,7 +565,7 @@ PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId , char * name , char
}
// form parameters
char *keyForm_status;
char *keyForm_status = NULL;
char * valueForm_status;
keyValuePair_t *keyPairForm_status = 0;
if (status != NULL)
@@ -594,10 +603,16 @@ end:
list_free(localVarContentType);
free(localVarPath);
free(localVarToReplace_petId);
free(keyForm_name);
if (keyForm_name) {
free(keyForm_name);
keyForm_name = NULL;
}
free(valueForm_name);
keyValuePair_free(keyPairForm_name);
free(keyForm_status);
if (keyForm_status) {
free(keyForm_status);
keyForm_status = NULL;
}
free(valueForm_status);
keyValuePair_free(keyPairForm_status);
@@ -638,7 +653,7 @@ PetAPI_uploadFile(apiClient_t *apiClient, long petId , char * additionalMetadata
// form parameters
char *keyForm_additionalMetadata;
char *keyForm_additionalMetadata = NULL;
char * valueForm_additionalMetadata;
keyValuePair_t *keyPairForm_additionalMetadata = 0;
if (additionalMetadata != NULL)
@@ -650,7 +665,7 @@ PetAPI_uploadFile(apiClient_t *apiClient, long petId , char * additionalMetadata
}
// form parameters
char *keyForm_file;
char *keyForm_file = NULL;
binary_t* valueForm_file;
keyValuePair_t *keyPairForm_file = 0;
if (file != NULL)
@@ -696,10 +711,16 @@ PetAPI_uploadFile(apiClient_t *apiClient, long petId , char * additionalMetadata
list_free(localVarContentType);
free(localVarPath);
free(localVarToReplace_petId);
free(keyForm_additionalMetadata);
if (keyForm_additionalMetadata) {
free(keyForm_additionalMetadata);
keyForm_additionalMetadata = NULL;
}
free(valueForm_additionalMetadata);
free(keyPairForm_additionalMetadata);
free(keyForm_file);
if (keyForm_file) {
free(keyForm_file);
keyForm_file = NULL;
}
// free(fileVar_file->data);
// free(fileVar_file);
free(keyPairForm_file);