diff --git a/gb.xml/src/html/hdocument.cpp b/gb.xml/src/html/hdocument.cpp index 4f83807ea..5f924efae 100644 --- a/gb.xml/src/html/hdocument.cpp +++ b/gb.xml/src/html/hdocument.cpp @@ -136,8 +136,16 @@ Element* HtmlDocument::getFaviconElement() void HtmlDocument::getGBBase(char *&base, size_t &len) { Attribute *attr = getBaseElement()->getAttribute("href", 4); - base = attr->attrValue; - len = attr->lenAttrValue; + if(attr) + { + base = attr->attrValue; + len = attr->lenAttrValue; + } + else + { + base = 0; + len = 0; + } } void HtmlDocument::setBase(char *content, size_t len) @@ -148,8 +156,16 @@ void HtmlDocument::setBase(char *content, size_t len) void HtmlDocument::getGBFavicon(char *&base, size_t &len) { Attribute *attr = getFaviconElement()->getAttribute("href", 4); - base = attr->attrValue; - len = attr->lenAttrValue; + if(attr) + { + base = attr->attrValue; + len = attr->lenAttrValue; + } + else + { + base = 0; + len = 0; + } } void HtmlDocument::setFavicon(char *content, size_t len) diff --git a/gb.xml/src/utils.cpp b/gb.xml/src/utils.cpp index 1cd9a5c1a..c37c68d89 100644 --- a/gb.xml/src/utils.cpp +++ b/gb.xml/src/utils.cpp @@ -193,14 +193,16 @@ XMLParseException::XMLParseException(const char *nerror, const char *data, const memcpy(error, nerror, lenError); //Parse error : (errorText) !\n Line 123456789 , Column 123456789 : \n (near) - errorWhat = (char*)malloc(61 + lenError + lenNear); - memset(errorWhat, 0, 61 + lenError + lenNear); - sprintf(errorWhat, "Parse error : %s !\n Line %zu , Column %zu : \n %s", error, line, column, near); - errorWhat[60 + lenError + lenNear] = 0; if(posFailed == 0) return; if(posFailed > data + lenData || posFailed < data) return; AnalyzeText(data, lenData, posFailed); + + + errorWhat = (char*)malloc(61 + lenError + lenNear); + memset(errorWhat, 0, 61 + lenError + lenNear); + sprintf(errorWhat, "Parse error : %s !\n Line %zu , Column %zu : \n %s", error, line, column, near); + errorWhat[60 + lenError + lenNear] = 0; @@ -214,7 +216,6 @@ XMLParseException::~XMLParseException() throw() void XMLParseException::AnalyzeText(const char *text, const size_t lenText, const char *posFailed) throw() { - for(const char *pos = text; pos < posFailed; ++pos) { ++column;