Bug in Edit Comment?

Discussions about the WinBoard protocol. Here you can also report bugs and request new features.

Moderators: hgm, Andres Valverde

Bug in Edit Comment?

Postby John Cheetham » 20 Jul 2011, 19:50

This relates to xboard from the savannah git master branch.

When I do Edit comment, enter a comment, click the save changes button, then click the OK button xboard crashes with a message 'double free or corruption'.
It fails on line 786 if(*dest) free(*dest); in GenericReadout in xoptions.c.

Maybe it needs to malloc the memory for the comment text when processing it in the SaveChanges function.

I get a similar issue with Edit Tags.

JC
John Cheetham
 
Posts: 11
Joined: 28 Mar 2011, 07:36

Re: Bug in Edit Comment?

Postby H.G.Muller » 21 Jul 2011, 18:20

Well, ReplaceComment actually did malloc the memory. The error was more subtle than that. There was a global variable commentText that acted as underlying setting for the text widget, and would receive the result during GenericReadout on OK. But GenericReadout always frees any old non-NULL value.

The problem was that this same variable was used as a temporary to readout the text using GetWidgetText from SaveChanges, and it was not malloc'ed there, but did get a non-NULL value because of it. So then the OK crashed it. I never tested this, because I always used Cancel after Save Changes to close the popup, because the stuff was already saved...

I fixed it by making the temporary variable in SaveChanges a local one.

I guess using GetWidgetText here is actually an inconsistency; I especially equipped GenericReadout with an argument to allow reading out of a single option from the list. So I guess a better fix would be to use GenericReadout(0) in stead of GetWidgetText(&currentoption[0], &commentText), as GenericReadout would have used malloc in assigning the value to commentText.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL


Return to WinBoard development and bugfixing

Who is online

Users browsing this forum: No registered users and 4 guests