diff options
author | Ravi Prasad RK <ravi.rk@samsung.com> | 2016-04-14 10:46:55 +0530 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2016-04-14 09:33:10 +0300 |
commit | 496afe6f6ddb3a65c9ed300d74485789a1269207 (patch) | |
tree | e9d3b06688cfb27725db094223001b4101e30a2e /gweb | |
parent | a84f5f7a72455a8ad0cbdc261331c97c54490d35 (diff) | |
download | connman-496afe6f6ddb3a65c9ed300d74485789a1269207.tar.gz |
gweb: Add NULL check before use
As per code logic, 'begin' and 'end' will never be NULL.
So, NULL check for g_strdup() call is redundant.
Diffstat (limited to 'gweb')
-rw-r--r-- | gweb/gweb.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/gweb/gweb.c b/gweb/gweb.c index 5f18a0e6..6ce5028a 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1465,6 +1465,9 @@ GWebParser *g_web_parser_new(const char *begin, const char *end, { GWebParser *parser; + if (!begin || !end) + return NULL; + parser = g_try_new0(GWebParser, 1); if (!parser) return NULL; @@ -1473,12 +1476,6 @@ GWebParser *g_web_parser_new(const char *begin, const char *end, parser->begin_token = g_strdup(begin); parser->end_token = g_strdup(end); - - if (!parser->begin_token) { - g_free(parser); - return NULL; - } - parser->func = func; parser->user_data = user_data; |