summaryrefslogtreecommitdiff
path: root/entities.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-04-24 12:12:30 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-04-24 12:12:30 +0000
commit122376b8efbff2cd6b62af2dedcdea05e07f5766 (patch)
tree927e1faa2e1367c140a821a6a9202a43f1342ea0 /entities.c
parent43dadebd413fe17a64e6bccb9484520e2c5d5310 (diff)
downloadlibxml2-122376b8efbff2cd6b62af2dedcdea05e07f5766.tar.gz
Staring to receive bug reports on 2.3.7:
- entities.c: xmlEncodeEntitiesReentrant fixed a few accesses to doc where it wasn't checked against NULL reported by Jens Laas Daniel
Diffstat (limited to 'entities.c')
-rw-r--r--entities.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/entities.c b/entities.c
index 22971cc8..3e6b581d 100644
--- a/entities.c
+++ b/entities.c
@@ -643,7 +643,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
*/
*out++ = *cur;
} else if (*cur >= 0x80) {
- if ((doc->encoding != NULL) || (html)) {
+ if (((doc != NULL) && (doc->encoding != NULL)) || (html)) {
/*
* Bjørn Reese <br@sseusa.com> provided the patch
xmlChar xc;
@@ -664,7 +664,8 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
if (*cur < 0xC0) {
xmlGenericError(xmlGenericErrorContext,
"xmlEncodeEntitiesReentrant : input not UTF-8\n");
- doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
+ if (doc != NULL)
+ doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
snprintf(buf, sizeof(buf), "&#%d;", *cur);
buf[sizeof(buf) - 1] = 0;
ptr = buf;
@@ -695,7 +696,8 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
if ((l == 1) || (!IS_CHAR(val))) {
xmlGenericError(xmlGenericErrorContext,
"xmlEncodeEntitiesReentrant : char out of range\n");
- doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
+ if (doc != NULL)
+ doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
snprintf(buf, sizeof(buf), "&#%d;", *cur);
buf[sizeof(buf) - 1] = 0;
ptr = buf;