Skip to content

Commit

Permalink
Change: Use result of g_string_free when arg 2 is FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Oct 5, 2023
2 parents 597e9a1 + c60a8f7 commit 3f9922b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
16 changes: 2 additions & 14 deletions src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5599,7 +5599,6 @@ char *
restore_gmp (gvm_connection_t *connection, credentials_t *credentials,
params_t *params, cmd_response_data_t *response_data)
{
GString *xml;
gchar *ret;
entity_t entity;
const char *target_id;
Expand All @@ -5608,8 +5607,6 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials,

CHECK_VARIABLE_INVALID (target_id, "Restore")

xml = g_string_new ("");

/* Restore the resource. */

if (gvm_connection_sendf (connection,
Expand All @@ -5618,7 +5615,6 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials,
target_id)
== -1)
{
g_string_free (xml, TRUE);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
Expand All @@ -5629,9 +5625,8 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials,
response_data);
}

if (read_entity_and_string_c (connection, &entity, &xml))
if (read_entity_and_string_c (connection, &entity, NULL))
{
g_string_free (xml, TRUE);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
Expand All @@ -5647,7 +5642,6 @@ restore_gmp (gvm_connection_t *connection, credentials_t *credentials,
ret = response_from_entity (connection, credentials, params, entity,
"Restore", response_data);
free_entity (entity);
g_string_free (xml, FALSE);
return ret;
}

Expand All @@ -5665,17 +5659,13 @@ char *
empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials,
params_t *params, cmd_response_data_t *response_data)
{
GString *xml;
gchar *ret;
entity_t entity;

xml = g_string_new ("");

/* Empty the trash. */

if (gvm_connection_sendf (connection, "<empty_trashcan/>") == -1)
{
g_string_free (xml, TRUE);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
Expand All @@ -5685,9 +5675,8 @@ empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials,
response_data);
}

if (read_entity_and_string_c (connection, &entity, &xml))
if (read_entity_and_string_c (connection, &entity, NULL))
{
g_string_free (xml, TRUE);
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
Expand All @@ -5702,7 +5691,6 @@ empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials,
ret = response_from_entity (connection, credentials, params, entity,
"Empty Trashcan", response_data);
free_entity (entity);
g_string_free (xml, FALSE);
return ret;
}

Expand Down
6 changes: 1 addition & 5 deletions src/gsad_gmp_arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ gmp_arguments_string (gmp_arguments_t *arguments)
g_free (escaped_value);
}

gchar *retval = argumentslist->str;

g_string_free (argumentslist, FALSE);

return retval;
return g_string_free (argumentslist, FALSE);
}

gboolean
Expand Down

0 comments on commit 3f9922b

Please sign in to comment.