diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2017-08-26 10:30:47 +0200 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2017-10-15 12:38:51 +0000 |
commit | 9d49e1316689ae05d31efc866f04ac12cd051085 (patch) | |
tree | f51b835fd490fe6be49268a114014f597f47c252 /epan/dtd_parse.l | |
parent | 37ccb77a1ab845075465c2d86eea9e8e21abc273 (diff) |
Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions:
- g_free "If mem is NULL it simply returns"
https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free
- g_slist_free(_full)? "NULL is considered to be the empty list"
https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html
- g_strfreev "If str_array is NULL, this function simply returns."
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev
- g_slice_free "If mem is NULL, this macro does nothing."
https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free
- g_match_info_free "not NULL... otherwise does nothing"
https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free
- dfilter_free defined in Wireshark code. Returns early when passed NULL
epan/dfilter/dfilter.c
They were also removed around calls to g_strdup where applicable:
- g_strdup "If str is NULL it returns NULL."
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup
Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04
Reviewed-on: https://code.wireshark.org/review/23406
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan/dtd_parse.l')
-rw-r--r-- | epan/dtd_parse.l | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/epan/dtd_parse.l b/epan/dtd_parse.l index 37f3bcf5c4..4c250c252e 100644 --- a/epan/dtd_parse.l +++ b/epan/dtd_parse.l @@ -110,10 +110,10 @@ DIAG_OFF(sign-compare) static dtd_build_data_t* build_data; - static void set_proto_name (gchar* val) { if(build_data->proto_name) g_free(build_data->proto_name); build_data->proto_name = g_strdup(val); } - static void set_media_type (gchar* val) { if(build_data->media_type) g_free(build_data->media_type); build_data->media_type = g_strdup(val); } - static void set_proto_root (gchar* val) { if(build_data->proto_root) g_free(build_data->proto_root); build_data->proto_root = g_strdup(val); } - static void set_description (gchar* val) { if(build_data->description) g_free(build_data->description); build_data->description = g_strdup(val); } + static void set_proto_name (gchar* val) { g_free(build_data->proto_name); build_data->proto_name = g_strdup(val); } + static void set_media_type (gchar* val) { g_free(build_data->media_type); build_data->media_type = g_strdup(val); } + static void set_proto_root (gchar* val) { g_free(build_data->proto_root); build_data->proto_root = g_strdup(val); } + static void set_description (gchar* val) { g_free(build_data->description); build_data->description = g_strdup(val); } static void set_recursive (gchar* val) { build_data->recursion = ( g_ascii_strcasecmp(val,"yes") == 0 ) ? TRUE : FALSE; } #ifdef DEBUG_DTD_PARSER @@ -244,7 +244,7 @@ squoted ['][^\']*['] <XMLPI>{stop_xmlpi} BEGIN DTD; <LOCATION>{get_location_xmlpi} { - if(yyextra->location) g_free(yyextra->location); + g_free(yyextra->location); yyextra->location = g_strdup(yytext); BEGIN DONE; } @@ -421,8 +421,7 @@ extern dtd_build_data_t* dtd_parse(GString* s) { Dtd_Parse_lex_destroy(scanner); - if (state.location) - g_free(state.location); + g_free(state.location); DtdParseFree(state.pParser, g_free); |