[yelp] Check the strstr() return value before using it
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] Check the strstr() return value before using it
- Date: Mon, 21 Jan 2019 14:40:32 +0000 (UTC)
commit 9847b4320718f5a2f0f61b4142268d6f3e273f6f
Author: Tomas Popela <tpopela redhat com>
Date: Mon Jul 23 11:56:21 2018 +0200
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".
libyelp/yelp-uri-builder.c | 7 ++++---
1 file 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]