[libxml2] Pointer dereferenced before null check
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Pointer dereferenced before null check
- Date: Mon, 6 Oct 2014 12:08:39 +0000 (UTC)
commit 91309d3a1d45aa70aa223b1e3ef1b23ab1c0cf36
Author: Daniel Veillard <veillard redhat com>
Date: Mon Oct 6 20:07:19 2014 +0800
Pointer dereferenced before null check
For https://bugzilla.gnome.org/show_bug.cgi?id=707027
A few pointer dereference before NULL check fixed.
Removed a useless test
xmlreader.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/xmlreader.c b/xmlreader.c
index 2607a70..f19e123 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -286,7 +286,10 @@ static void
xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
xmlDictPtr dict;
- dict = reader->ctxt->dict;
+ if ((reader != NULL) && (reader->ctxt != NULL))
+ dict = reader->ctxt->dict;
+ else
+ dict = NULL;
if (cur == NULL) return;
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
@@ -323,7 +326,7 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
static void
xmlTextReaderFreePropList(xmlTextReaderPtr reader, xmlAttrPtr cur) {
xmlAttrPtr next;
- if (cur == NULL) return;
+
while (cur != NULL) {
next = cur->next;
xmlTextReaderFreeProp(reader, cur);
@@ -344,7 +347,10 @@ xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlNodePtr next;
xmlDictPtr dict;
- dict = reader->ctxt->dict;
+ if ((reader != NULL) && (reader->ctxt != NULL))
+ dict = reader->ctxt->dict;
+ else
+ dict = NULL;
if (cur == NULL) return;
if (cur->type == XML_NAMESPACE_DECL) {
xmlFreeNsList((xmlNsPtr) cur);
@@ -421,7 +427,10 @@ static void
xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlDictPtr dict;
- dict = reader->ctxt->dict;
+ if ((reader != NULL) && (reader->ctxt != NULL))
+ dict = reader->ctxt->dict;
+ else
+ dict = NULL;
if (cur->type == XML_DTD_NODE) {
xmlFreeDtd((xmlDtdPtr) cur);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]