diff options
author | Timm Bäder <mail@baedert.org> | 2016-07-14 14:22:55 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2016-07-14 18:30:32 +0200 |
commit | b11a1664cd4dfcc62b07b4a68adc220fd1eb8305 (patch) | |
tree | 3b2bcf53dbc1fd6f9f8c8c25931af45826a50e4b | |
parent | eb4f757691ccac55daa2e87ff8843a4812004276 (diff) | |
download | librest-b11a1664cd4dfcc62b07b4a68adc220fd1eb8305.tar.gz |
Add more missing precondition checks
-rw-r--r-- | rest/rest-proxy.c | 1 | ||||
-rw-r--r-- | rest/rest-xml-node.c | 14 | ||||
-rw-r--r-- | rest/rest-xml-parser.c | 1 |
3 files changed, 14 insertions, 2 deletions
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c index ca42aac..ff2b394 100644 --- a/rest/rest-proxy.c +++ b/rest/rest-proxy.c @@ -526,6 +526,7 @@ rest_proxy_set_user_agent (RestProxy *proxy, const char *user_agent) { g_return_if_fail (REST_IS_PROXY (proxy)); + g_return_if_fail (user_agent != NULL); g_object_set (proxy, "user-agent", user_agent, NULL); } diff --git a/rest/rest-xml-node.c b/rest/rest-xml-node.c index 1a74bcb..9655dc1 100644 --- a/rest/rest-xml-node.c +++ b/rest/rest-xml-node.c @@ -215,6 +215,8 @@ const gchar * rest_xml_node_get_attr (RestXmlNode *node, const gchar *attr_name) { + g_return_val_if_fail (attr_name != NULL, NULL); + return g_hash_table_lookup (node->attrs, attr_name); } @@ -238,6 +240,7 @@ rest_xml_node_find (RestXmlNode *start, const char *tag_interned; g_return_val_if_fail (start, NULL); + g_return_val_if_fail (tag != NULL, NULL); g_return_val_if_fail (start->ref_count > 0, NULL); tag_interned = g_intern_string (tag); @@ -331,6 +334,7 @@ rest_xml_node_add_child (RestXmlNode *parent, const char *tag) RestXmlNode *node; char *escaped; + g_return_val_if_fail (parent, NULL); g_return_val_if_fail (tag && *tag, NULL); escaped = g_markup_escape_text (tag, -1); @@ -372,7 +376,11 @@ rest_xml_node_add_attr (RestXmlNode *node, const char *attribute, const char *value) { - g_return_if_fail (node && attribute && *attribute); + g_return_if_fail (node); + g_return_if_fail (attribute); + g_return_if_fail (*attribute); + g_return_if_fail (value); + g_return_if_fail (*value); g_hash_table_insert (node->attrs, g_markup_escape_text (attribute, -1), @@ -389,7 +397,9 @@ rest_xml_node_add_attr (RestXmlNode *node, void rest_xml_node_set_content (RestXmlNode *node, const char *value) { - g_return_if_fail (node && value && *value); + g_return_if_fail (node); + g_return_if_fail (value); + g_return_if_fail (*value); g_free (node->content); node->content = g_markup_escape_text (value, -1); diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c index 0e0f467..ffa6ff3 100644 --- a/rest/rest-xml-parser.c +++ b/rest/rest-xml-parser.c @@ -91,6 +91,7 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser, GQueue nodes = G_QUEUE_INIT; g_return_val_if_fail (REST_IS_XML_PARSER (parser), NULL); + g_return_val_if_fail (data != NULL, NULL); if (len == -1) len = strlen (data); |