[libsoup] soup-message-headers: Add sanity check into content_type_setter()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup-message-headers: Add sanity check into content_type_setter()
- Date: Mon, 25 Jun 2018 16:13:52 +0000 (UTC)
commit ef10fc84788962239567b564806427e84548c2b8
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 25 18:15:00 2018 +0200
soup-message-headers: Add sanity check into content_type_setter()
To address a Coverity Scan/clang warning.
https://bugzilla.gnome.org/show_bug.cgi?id=781771
libsoup/soup-message-headers.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/libsoup/soup-message-headers.c b/libsoup/soup-message-headers.c
index 16e487af..7522702a 100644
--- a/libsoup/soup-message-headers.c
+++ b/libsoup/soup-message-headers.c
@@ -1324,18 +1324,20 @@ static void
content_type_setter (SoupMessageHeaders *hdrs, const char *value)
{
g_free (hdrs->content_type);
+ hdrs->content_type = NULL;
+
if (value) {
- char *content_type, *p;
+ char *content_type = NULL, *p;
parse_content_foo (hdrs, "Content-Type", &content_type, NULL);
+ g_return_if_fail (content_type != NULL);
+
p = strpbrk (content_type, " /");
- if (!p || *p != '/' || strpbrk (p + 1, " /")) {
+ if (!p || *p != '/' || strpbrk (p + 1, " /"))
g_free (content_type);
- hdrs->content_type = NULL;
- } else
+ else
hdrs->content_type = content_type;
- } else
- hdrs->content_type = NULL;
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]