Error when calling Amarok::decapitateString()

Nicholas Sinlock isolatedincident at gmail.com
Thu Jan 8 19:03:55 UTC 2009


Mark Kretschmann wrote:
> On Thu, Jan 8, 2009 at 7:01 PM, Nicholas Sinlock
> <isolatedincident at gmail.com> wrote:
>   
>> #10 0xb6ad69b2 in qFatal(char const*, ...) () from /usr/lib/libQtCore.so.4
>> #11 0xb6ad6a45 in qt_assert(char const*, char const*, int) () from
>> /usr/lib/libQtCore.so.4
>> #12 0xb79ed2cc in QString::at (this=0xbfa34604, i=17) at
>> /usr/include/QtCore/qstring.h:644
>> #13 0xb7a80a98 in Amarok::decapitateString (input=@0xbfa34600,
>> ref=@0xbfa34604) at
>> /home/nsinlock/kde/sources/trunk/extragear/multimedia/amarok/src/App.cpp:1011
>>     
>
> If you look at the line causing this...
>
>   if( t.endsWith( ' ' ) || !ref.at( t.length() ).isLetterOrNumber() )
> // common part ends with a space or complete word
>
> ...you can see that the crash is likely caused by an out-of-bounds
> array access. So the index of QString::at() is probably bigger than
> the size of the string.
>
>   
You hit the nail on the head.  Changed the line to if( t.endsWith(' ' ) 
|| !ref.at( t.length() - 1 ).isLetterOrNumber() )
and it's fine now.   Thanks for all the help.

Guess I'll see about possibly improving the function itself since 
someone mentioned that.




More information about the Amarok mailing list