Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Sep 16, 2024
1 parent 4f9d16c commit 1bc1415
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions util/jsonpull.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

/**
* @brief Escapes a string according to the JSON or JSONPath standard
*
* @param[in] string The string to escape
* @param[in] single_quote Whether to escape single quotes
*
* @return The escaped string
*/
gchar *
gvm_json_string_escape (const char *string, gboolean single_quote)
Expand All @@ -27,8 +32,7 @@ gvm_json_string_escape (const char *string, gboolean single_quote)
unsigned char character = *point;

if ((character > 31) && (character != '\\')
&& (single_quote || character != '\"')
&& (!single_quote || character != '\''))
&& (single_quote ? (character != '\'') : (character != '\"')))
{
g_string_append_c (escaped, character);
}
Expand Down Expand Up @@ -115,6 +119,8 @@ void
gvm_json_pull_event_reset (gvm_json_pull_event_t *event)
{
cJSON_free (event->value);
if (event->error_message)
g_free (event->error_message);

Check warning on line 123 in util/jsonpull.c

View check run for this annotation

Codecov / codecov/patch

util/jsonpull.c#L123

Added line #L123 was not covered by tests
memset (event, 0, sizeof (gvm_json_pull_event_t));
}

Expand All @@ -127,6 +133,8 @@ void
gvm_json_pull_event_cleanup (gvm_json_pull_event_t *event)
{
cJSON_free (event->value);
if (event->error_message)
g_free (event->error_message);
memset (event, 0, sizeof (gvm_json_pull_event_t));
}

Expand Down Expand Up @@ -230,6 +238,8 @@ gvm_json_pull_check_parse_buffer_size (const char *value_type,
/**
* @brief Reads the next character in a pull parser input stream.
*
* @param[in] parser The parser to read the next character from
*
* @return The character code, GVM_JSON_CHAR_ERROR or GVM_JSON_CHAR_EOF.
*/
static int
Expand Down Expand Up @@ -773,12 +783,6 @@ gvm_json_pull_parser_next (gvm_json_pull_parser_t *parser,
return;
}

if (parser->expect == GVM_JSON_PULL_EXPECT_KEY)
{
if (gvm_json_pull_parse_key (parser, event))
return;
}

if (parser->expect == GVM_JSON_PULL_EXPECT_COMMA)
{
if (gvm_json_pull_parse_comma (parser, event))
Expand Down

0 comments on commit 1bc1415

Please sign in to comment.