On Mon, Nov 05, 2007 at 08:27:05AM +0100, Abdelrazak Younes wrote:
> Andre Poenitz wrote:
>> On Sun, Nov 04, 2007 at 05:39:43PM +0100, Jürgen Spitzmüller wrote:
>>> Andre Poenitz wrote:
>>>> We definitely should switch to a more user friendly error handling
>>>> then plain crashs. While it might be annoying that one cannot
>>>> properly paste form the clipboard we should not crash...
>>> On Linux, it only crashes with --enable-stdlib-debug. The attached
>>> patch fixes this particular crash for me, but it's rater a shot in the
>>> dark.
>>>
>>> Does it make sense, André?
>> The direction is ok. Probably in the Old Days 'error()' never returned..
>>> Jürgen
>>> Index: src/mathed/MathParser.cpp
>>> ===================================================================
>>> --- src/mathed/MathParser.cpp       (Revision 21417)
>>> +++ src/mathed/MathParser.cpp       (Arbeitskopie)
>>> @@ -463,8 +463,12 @@
>>>   char_type Parser::getChar()
>>>  {
>>> -   if (!good())
>>> +   if (!good()) {
>>>             error("The input stream is not well...");
>>> +           putback();
>>> +           char_type dummy;
>>> +           return dummy;
>> The last two lines are equivalent to 'return char_type(); '
>
> Well char_type is an unsigned int so I don't know what char_type() would  
> return (isn't that undefined behaviour?).

Urm. You are right, it's not initialized. So practically it'd return
crap, theoretically it should be undefined behaviour (not 100% sure,
would need to look it up...).

> I suggest to return 0 instead.

Which is more or less equivalent to my suggestion of char_type() - a
default- and thereyby in this case zero-initialized value of type
'char_type'. Of cause, '0' is shorter.

Andre'

Reply via email to