diff options
author | Tomas Popela <tpopela@redhat.com> | 2018-07-23 11:56:21 +0200 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2019-01-21 14:38:59 +0000 |
commit | 9847b4320718f5a2f0f61b4142268d6f3e273f6f (patch) | |
tree | 65bb74938f702a290dc22dfd1d192f75aa60316e | |
parent | cbf737eaa23f22fb73b439a2c76a0e18080d7a87 (diff) | |
download | yelp-9847b4320718f5a2f0f61b4142268d6f3e273f6f.tar.gz |
Check the strstr() return value before using it
yelp-3.28.1/libyelp/yelp-uri-builder.c:81: returned_null: "strstr" returns null (checked 10 out of 12 times).
yelp-3.28.1/libyelp/yelp-uri-builder.c:81: var_assigned: Assigning: "resource" = null return value from "strstr".
yelp-3.28.1/libyelp/yelp-uri-builder.c:82: dereference: Incrementing a pointer which might be null: "resource".
-rw-r--r-- | libyelp/yelp-uri-builder.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libyelp/yelp-uri-builder.c b/libyelp/yelp-uri-builder.c index bb34d202..58a53ac9 100644 --- a/libyelp/yelp-uri-builder.c +++ b/libyelp/yelp-uri-builder.c @@ -78,9 +78,10 @@ build_yelp_uri (const gchar *uri_str) memmove (uri, uri + BOGUS_PREFIX_LEN, strlen (uri) - BOGUS_PREFIX_LEN + 1); /* Remove the leading slash */ - resource = strstr (uri, ":"); - resource++; - memmove (resource, resource + 1, strlen (resource)); + if ((resource = strstr (uri, ":"))) { + resource++; + memmove (resource, resource + 1, strlen (resource)); + } /* Remove the trailing slash if any */ path_len = strlen (uri); |