diff options
author | Руслан Ижбулатов <lrn1986@gmail.com> | 2015-10-31 22:45:46 +0000 |
---|---|---|
committer | Руслан Ижбулатов <lrn1986@gmail.com> | 2015-11-01 10:13:27 +0000 |
commit | f09307d1d467e0c25bd6f00bd689fdd5b858a360 (patch) | |
tree | c06336ea1eeb61b2cd522a71084ddde7e48320de /csslint/csslint.c | |
parent | d03fa2148fe0af4ebd96f1fa74772054197aaa02 (diff) | |
download | libcroco-f09307d1d467e0c25bd6f00bd689fdd5b858a360.tar.gz |
Fix unused status variable in evaluate_selectors()
* Add an end label to go to on error
* Clean up xml_doc at the end
* Fix a miscleaning of xpath_object
* Unref sheets after they are given to a cascade
* Return status at the end
https://bugzilla.gnome.org/show_bug.cgi?id=710076
Diffstat (limited to 'csslint/csslint.c')
-rw-r--r-- | csslint/csslint.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/csslint/csslint.c b/csslint/csslint.c index ab38c4a..beb60c4 100644 --- a/csslint/csslint.c +++ b/csslint/csslint.c @@ -327,7 +327,8 @@ evaluate_selectors (gchar * a_xml_path, xml_doc = xmlParseFile (a_xml_path); if (!xml_doc) { g_printerr ("Error: Could not parse file %s\n", a_xml_path); - return CR_ERROR; + status = CR_ERROR; + goto end; } if (a_author_sheet_path) { status = cr_om_parser_simply_parse_file @@ -351,31 +352,46 @@ evaluate_selectors (gchar * a_xml_path, } } cascade = cr_cascade_new (author_sheet, user_sheet, ua_sheet); + + if (author_sheet) + cr_stylesheet_unref (author_sheet); + + if (user_sheet) + cr_stylesheet_unref (user_sheet); + + if (ua_sheet) + cr_stylesheet_unref (ua_sheet); + if (!cascade) { g_printerr ("Could not instanciate the cascade\n"); - return CR_ERROR; + status = CR_ERROR; + goto end; } sel_eng = cr_sel_eng_new (); if (!sel_eng) { g_printerr ("Error: Could not instanciate the selection engine\n"); - return CR_ERROR; + status = CR_ERROR; + goto end; } xpath_context = xmlXPathNewContext (xml_doc); if (!xpath_context) { g_printerr ("Error: Could not instanciate the xpath context\n"); - return CR_ERROR; + status = CR_ERROR; + goto end; } xpath_object = xmlXPathEvalExpression ((const xmlChar *) a_xpath, xpath_context); if (!xpath_object) { g_printerr ("Error: Could not evaluate xpath expression\n"); - return CR_ERROR; + status = CR_ERROR; + goto end; } if (xpath_object->type != XPATH_NODESET || !xpath_object->nodesetval) { g_printerr ("Error: xpath does not evalualuate to a node set\n"); - return CR_ERROR; + status = CR_ERROR; + goto end; } for (i = 0; i < xpath_object->nodesetval->nodeNr; i++) { @@ -386,11 +402,13 @@ evaluate_selectors (gchar * a_xml_path, } } + end: + if (xpath_context) { xmlXPathFreeContext (xpath_context); xpath_context = NULL; } - if (xpath_context) { + if (xpath_object) { xmlXPathFreeObject (xpath_object); xpath_object = NULL; } @@ -400,8 +418,14 @@ evaluate_selectors (gchar * a_xml_path, } if (cascade) { cr_cascade_destroy (cascade); + cascade = NULL; } - return CR_OK; + if (xml_doc) { + xmlFreeDoc (xml_doc); + xml_doc = NULL; + } + + return status; } /*************************** |