You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Aleksandr Vinokurov <al...@gmail.com> on 2008/05/07 13:42:11 UTC

Assertion failed with XalanDOMString::substr


Hello all,

Seems that I've discovered an assertion failure with this code:

>-----------------------<cut>-------------------------<

#include <xalanc/XalanTransformer/XalanTransformer.hpp>
#include <xalanc/XalanDOM/XalanDOMString.hpp>

XALAN_USING(XALAN_CPP_NAMESPACE, XalanDOMString)

int main(void) {
        XALAN_USING_XERCES(XMLPlatformUtils)
        XALAN_USING_XALAN(XalanTransformer)

        XMLPlatformUtils::Initialize();
        XalanTransformer::initialize();

        XalanDOMString a("xxxxxxxxxxx"), b;

        a.substr(b);        //the same as a.substr(b, 0,
XalanDOMString::npos);

        return 0;
}

>-----------------------<cut>-------------------------<


Here goes the output:

>-----------------------<cut>-------------------------<
Assertion failed: thePosition < theSource.size() && thePosition + theCount
<= theSource.size(), file
/u02/home/avinokur/xalan-c/xml-xalan/c/src/xalanc/XalanDOM/XalanDOMString.cp
p, line 224
Abort (core dumped)
>-----------------------<cut>-------------------------<


I use 1.10.0 version of Xalan-C, and compile it on SunOS 5.9
Generic_118558-30 sun4u sparc SUNW,Sun-Fire-280R.

As I've found the assertion fails in "thePosition + theCount <=
theSource.size()" code, computing it to "0 + 4294967295 <= 11". Trying
"a.substr(b, 1)", the condition will be "1 + 4294967295 <= 11" which is "0 <
11" due to "typedef unsigned int    size_type;" code from
``xalanc/XalanDOM/XalanDOMString.hpp''.

Is it a bug or my misunderstanding of smth?


With best regards,
Aleksandr Vinokurov.



Re: Assertion failed with XalanDOMString::substr

Posted by David Bertoni <db...@apache.org>.
Aleksandr Vinokurov wrote:
> 
> Hello all,
> 
> Seems that I've discovered an assertion failure with this code:
> 
>> -----------------------<cut>-------------------------<
> 
> #include <xalanc/XalanTransformer/XalanTransformer.hpp>
> #include <xalanc/XalanDOM/XalanDOMString.hpp>
> 
> XALAN_USING(XALAN_CPP_NAMESPACE, XalanDOMString)
> 
> int main(void) {
>         XALAN_USING_XERCES(XMLPlatformUtils)
>         XALAN_USING_XALAN(XalanTransformer)
> 
>         XMLPlatformUtils::Initialize();
>         XalanTransformer::initialize();
> 
>         XalanDOMString a("xxxxxxxxxxx"), b;
> 
>         a.substr(b);        //the same as a.substr(b, 0,
> XalanDOMString::npos);
> 
>         return 0;
> }
> 
>> -----------------------<cut>-------------------------<
Yes, this is a bug.  Can you please create a Jira issue so we can track it:

https://issues.apache.org/jira/browse/XALANC

The fix is trivial.

Thanks,

Dave