fixed a problem occuring only in x86_64 when very large error messages are

* python/libxml.c: fixed a problem occuring only in x86_64 when
  very large error messages are raied to the Python handlers.
Daniel
This commit is contained in:
Daniel Veillard 2004-10-22 11:05:37 +00:00
parent 1a380b8924
commit ad9fb7c06f
4 changed files with 272 additions and 273 deletions

View File

@ -1,3 +1,8 @@
Fri Oct 22 21:04:20 CEST 2004 Daniel Veillard <daniel@veillard.com>
* python/libxml.c: fixed a problem occuring only in x86_64 when
very large error messages are raied to the Python handlers.
Thu Oct 21 18:03:21 CEST 2004 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c: fixed a memory bug

View File

@ -255,7 +255,7 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define if compiler has function prototypes */
/* Define to 1 if the C compiler supports function prototypes. */
#undef PROTOTYPES
/* Determine what socket length (socklen_t) data type is */
@ -273,6 +273,9 @@
/* Using the Win32 Socket implementation */
#undef _WINSOCKAPI_
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
/* Win32 Std C name mangling work-around */
#undef snprintf

View File

@ -1427,34 +1427,24 @@ static PyObject *libxml_xmlPythonErrorFuncHandler = NULL;
static PyObject *libxml_xmlPythonErrorFuncCtxt = NULL;
/* helper to build a xmlMalloc'ed string from a format and va_list */
/*
* disabled the loop, the repeated call to vsnprintf without reset of ap
* in case the initial buffer was too small segfaulted on x86_64
* we now directly vsnprintf on a large buffer.
*/
static char *
libxml_buildMessage(const char *msg, va_list ap)
{
int size;
int chars;
char *larger;
char *str;
str = (char *) xmlMalloc(150);
str = (char *) xmlMalloc(1000);
if (str == NULL)
return NULL;
size = 150;
while (1) {
chars = vsnprintf(str, size, msg, ap);
if ((chars > -1) && (chars < size))
break;
if (chars > -1)
size += chars + 1;
else
size += 100;
if ((larger = (char *) xmlRealloc(str, size)) == NULL) {
xmlFree(str);
return NULL;
}
str = larger;
}
chars = vsnprintf(str, 999, msg, ap);
if (chars >= 998)
str[999] = 0;
return str;
}
@ -1464,10 +1454,10 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
...)
{
va_list ap;
char *str;
PyObject *list;
PyObject *message;
PyObject *result;
char str[1000];
#ifdef DEBUG_ERROR
printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
@ -1480,13 +1470,14 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
va_end(ap);
} else {
va_start(ap, msg);
str = libxml_buildMessage(msg,ap);
if (vsnprintf(str, 999, msg, ap) >= 998)
str[999] = 0;
va_end(ap);
list = PyTuple_New(2);
PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
message = libxml_charPtrWrap(str);
message = libxml_charPtrConstWrap(str);
PyTuple_SetItem(list, 1, message);
result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
Py_XDECREF(list);

View File

@ -647,56 +647,6 @@ Class xmlDoc(xmlNode)
# functions from module xpointer
xpointerNewContext()
Class xpathContext()
# accessors
contextDoc()
contextNode()
contextPosition()
contextSize()
function()
functionURI()
setContextDoc()
setContextNode()
# functions from module python
registerXPathFunction()
# functions from module xpath
xpathEval()
xpathEvalExpression()
xpathFreeContext()
# functions from module xpathInternals
xpathNewParserContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
xpathRegisteredFuncsCleanup()
xpathRegisteredNsCleanup()
xpathRegisteredVariablesCleanup()
xpathVariableLookup()
xpathVariableLookupNS()
# functions from module xpointer
xpointerEval()
Class xmlAttribute(xmlNode)
Class catalog()
# functions from module catalog
add()
catalogIsEmpty()
convertSGMLCatalog()
dump()
remove()
resolve()
resolvePublic()
resolveSystem()
resolveURI()
Class xmlElement(xmlNode)
Class xmlAttr(xmlNode)
@ -715,100 +665,12 @@ Class xmlAttr(xmlNode)
# functions from module valid
removeID()
removeRef()
Class xmlTextReader(xmlTextReaderCore)
# functions from module xmlreader
AttributeCount()
BaseUri()
Close()
CurrentDoc()
CurrentNode()
Depth()
Expand()
GetAttribute()
GetAttributeNo()
GetAttributeNs()
GetParserProp()
GetRemainder()
HasAttributes()
HasValue()
IsDefault()
IsEmptyElement()
IsValid()
LocalName()
LookupNamespace()
MoveToAttribute()
MoveToAttributeNo()
MoveToAttributeNs()
MoveToElement()
MoveToFirstAttribute()
MoveToNextAttribute()
Name()
NamespaceUri()
NewDoc()
NewFd()
NewFile()
NewMemory()
NewWalker()
Next()
NextSibling()
NodeType()
Normalization()
Prefix()
Preserve()
QuoteChar()
Read()
ReadAttributeValue()
ReadInnerXml()
ReadOuterXml()
ReadState()
ReadString()
RelaxNGSetSchema()
RelaxNGValidate()
SetParserProp()
String()
Value()
XmlLang()
Class xmlReg()
# functions from module xmlregexp
regexpExec()
regexpIsDeterminist()
regexpPrint()
Class xmlEntity(xmlNode)
# functions from module parserInternals
handleEntity()
Class relaxNgSchema()
# functions from module relaxng
relaxNGDump()
relaxNGDumpTree()
relaxNGNewValidCtxt()
# functions from module xmlreader
RelaxNGSetSchema()
Class Schema()
# functions from module xmlschemas
schemaDump()
schemaNewValidCtxt()
Class Error()
# accessors
code()
domain()
file()
level()
line()
message()
# functions from module xmlerror
copyError()
resetError()
Class relaxNgValidCtxt()
# functions from module relaxng
@ -817,73 +679,6 @@ Class relaxNgValidCtxt()
relaxNGValidatePopElement()
relaxNGValidatePushCData()
relaxNGValidatePushElement()
Class xpathParserContext()
# accessors
context()
# functions from module xpathInternals
xpathAddValues()
xpathBooleanFunction()
xpathCeilingFunction()
xpathCompareValues()
xpathConcatFunction()
xpathContainsFunction()
xpathCountFunction()
xpathDivValues()
xpathEqualValues()
xpathErr()
xpathEvalExpr()
xpathFalseFunction()
xpathFloorFunction()
xpathFreeParserContext()
xpathIdFunction()
xpathLangFunction()
xpathLastFunction()
xpathLocalNameFunction()
xpathModValues()
xpathMultValues()
xpathNamespaceURIFunction()
xpathNextAncestor()
xpathNextAncestorOrSelf()
xpathNextAttribute()
xpathNextChild()
xpathNextDescendant()
xpathNextDescendantOrSelf()
xpathNextFollowing()
xpathNextFollowingSibling()
xpathNextNamespace()
xpathNextParent()
xpathNextPreceding()
xpathNextPrecedingSibling()
xpathNextSelf()
xpathNormalizeFunction()
xpathNotEqualValues()
xpathNotFunction()
xpathNumberFunction()
xpathParseNCName()
xpathParseName()
xpathPopBoolean()
xpathPopNumber()
xpathPopString()
xpathPositionFunction()
xpathRoot()
xpathRoundFunction()
xpathStartsWithFunction()
xpathStringFunction()
xpathStringLengthFunction()
xpathSubValues()
xpathSubstringAfterFunction()
xpathSubstringBeforeFunction()
xpathSubstringFunction()
xpathSumFunction()
xpathTranslateFunction()
xpathTrueFunction()
xpathValueFlipSign()
xpatherror()
# functions from module xpointer
xpointerEvalRangePredicate()
xpointerRangeToFunction()
Class parserCtxt(parserCtxtCore)
@ -991,6 +786,94 @@ Class xmlDtd(xmlNode)
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
Class relaxNgParserCtxt()
# functions from module relaxng
relaxNGParse()
relaxParserSetFlag()
Class xpathParserContext()
# accessors
context()
# functions from module xpathInternals
xpathAddValues()
xpathBooleanFunction()
xpathCeilingFunction()
xpathCompareValues()
xpathConcatFunction()
xpathContainsFunction()
xpathCountFunction()
xpathDivValues()
xpathEqualValues()
xpathErr()
xpathEvalExpr()
xpathFalseFunction()
xpathFloorFunction()
xpathFreeParserContext()
xpathIdFunction()
xpathLangFunction()
xpathLastFunction()
xpathLocalNameFunction()
xpathModValues()
xpathMultValues()
xpathNamespaceURIFunction()
xpathNextAncestor()
xpathNextAncestorOrSelf()
xpathNextAttribute()
xpathNextChild()
xpathNextDescendant()
xpathNextDescendantOrSelf()
xpathNextFollowing()
xpathNextFollowingSibling()
xpathNextNamespace()
xpathNextParent()
xpathNextPreceding()
xpathNextPrecedingSibling()
xpathNextSelf()
xpathNormalizeFunction()
xpathNotEqualValues()
xpathNotFunction()
xpathNumberFunction()
xpathParseNCName()
xpathParseName()
xpathPopBoolean()
xpathPopNumber()
xpathPopString()
xpathPositionFunction()
xpathRoot()
xpathRoundFunction()
xpathStartsWithFunction()
xpathStringFunction()
xpathStringLengthFunction()
xpathSubValues()
xpathSubstringAfterFunction()
xpathSubstringBeforeFunction()
xpathSubstringFunction()
xpathSumFunction()
xpathTranslateFunction()
xpathTrueFunction()
xpathValueFlipSign()
xpatherror()
# functions from module xpointer
xpointerEvalRangePredicate()
xpointerRangeToFunction()
Class SchemaParserCtxt()
# functions from module xmlschemas
schemaParse()
Class catalog()
# functions from module catalog
add()
catalogIsEmpty()
convertSGMLCatalog()
dump()
remove()
resolve()
resolvePublic()
resolveSystem()
resolveURI()
Class xmlNs(xmlNode)
@ -1014,51 +897,6 @@ Class xmlNs(xmlNode)
# functions from module xpathInternals
xpathNodeSetFreeNs()
Class inputBuffer(ioReadWrapper)
# functions from module xmlIO
grow()
push()
read()
# functions from module xmlreader
newTextReader()
Class relaxNgParserCtxt()
# functions from module relaxng
relaxNGParse()
relaxParserSetFlag()
Class outputBuffer(ioWriteWrapper)
# functions from module HTMLtree
htmlDocContentDumpFormatOutput()
htmlDocContentDumpOutput()
htmlNodeDumpFormatOutput()
htmlNodeDumpOutput()
# functions from module tree
nodeDumpOutput()
saveFileTo()
saveFormatFileTo()
# functions from module xmlIO
write()
writeString()
Class SchemaParserCtxt()
# functions from module xmlschemas
schemaParse()
Class SchemaValidCtxt()
# functions from module xmlschemas
schemaSetValidOptions()
schemaValidCtxtGetOptions()
schemaValidateDoc()
schemaValidateOneElement()
Class xmlTextReaderLocator()
# functions from module xmlreader
@ -1089,3 +927,165 @@ Class URI()
parseURIReference()
printURI()
saveUri()
Class xmlAttribute(xmlNode)
Class xpathContext()
# accessors
contextDoc()
contextNode()
contextPosition()
contextSize()
function()
functionURI()
setContextDoc()
setContextNode()
# functions from module python
registerXPathFunction()
# functions from module xpath
xpathEval()
xpathEvalExpression()
xpathFreeContext()
# functions from module xpathInternals
xpathNewParserContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
xpathRegisteredFuncsCleanup()
xpathRegisteredNsCleanup()
xpathRegisteredVariablesCleanup()
xpathVariableLookup()
xpathVariableLookupNS()
# functions from module xpointer
xpointerEval()
Class xmlElement(xmlNode)
Class xmlTextReader(xmlTextReaderCore)
# functions from module xmlreader
AttributeCount()
BaseUri()
Close()
CurrentDoc()
CurrentNode()
Depth()
Expand()
GetAttribute()
GetAttributeNo()
GetAttributeNs()
GetParserProp()
GetRemainder()
HasAttributes()
HasValue()
IsDefault()
IsEmptyElement()
IsValid()
LocalName()
LookupNamespace()
MoveToAttribute()
MoveToAttributeNo()
MoveToAttributeNs()
MoveToElement()
MoveToFirstAttribute()
MoveToNextAttribute()
Name()
NamespaceUri()
NewDoc()
NewFd()
NewFile()
NewMemory()
NewWalker()
Next()
NextSibling()
NodeType()
Normalization()
Prefix()
Preserve()
QuoteChar()
Read()
ReadAttributeValue()
ReadInnerXml()
ReadOuterXml()
ReadState()
ReadString()
RelaxNGSetSchema()
RelaxNGValidate()
SetParserProp()
String()
Value()
XmlLang()
Class xmlEntity(xmlNode)
# functions from module parserInternals
handleEntity()
Class Schema()
# functions from module xmlschemas
schemaDump()
schemaNewValidCtxt()
Class Error()
# accessors
code()
domain()
file()
level()
line()
message()
# functions from module xmlerror
copyError()
resetError()
Class relaxNgSchema()
# functions from module relaxng
relaxNGDump()
relaxNGDumpTree()
relaxNGNewValidCtxt()
# functions from module xmlreader
RelaxNGSetSchema()
Class inputBuffer(ioReadWrapper)
# functions from module xmlIO
grow()
push()
read()
# functions from module xmlreader
newTextReader()
Class SchemaValidCtxt()
# functions from module xmlschemas
schemaSetValidOptions()
schemaValidCtxtGetOptions()
schemaValidateDoc()
schemaValidateOneElement()
Class outputBuffer(ioWriteWrapper)
# functions from module HTMLtree
htmlDocContentDumpFormatOutput()
htmlDocContentDumpOutput()
htmlNodeDumpFormatOutput()
htmlNodeDumpOutput()
# functions from module tree
nodeDumpOutput()
saveFileTo()
saveFormatFileTo()
# functions from module xmlIO
write()
writeString()