After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 105291 - AccessibleTextChangedEvent_getChangeString semms to return const gchar*
AccessibleTextChangedEvent_getChangeString semms to return const gchar*
Status: RESOLVED FIXED
Product: at-spi
Classification: Platform
Component: api
unspecified
Other Linux
: Normal normal
: ---
Assigned To: bill.haneman
bill.haneman
Depends on:
Blocks:
 
 
Reported: 2003-02-05 11:41 UTC by remus draica
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (578 bytes, patch)
2003-02-14 09:53 UTC, padraig.obriain
none Details | Review
New patch (581 bytes, patch)
2003-03-05 16:53 UTC, padraig.obriain
none Details | Review
Updated patch (1.17 KB, patch)
2003-03-05 17:14 UTC, padraig.obriain
none Details | Review

Description remus draica 2003-02-05 11:41:43 UTC
AccessibleTextChangedEvent_getChangeString seems to return a const value.
According with API in at-spi/cspi/spi.h, returned value could be released
when no longer needed, but when user do that a crash happening. Other
negativ effect is that the pointer is valid only if the event is valid,
which, in my opinion is not OK.
Comment 1 padraig.obriain 2003-02-14 09:53:23 UTC
Created attachment 14315 [details] [review]
Proposed patch
Comment 2 padraig.obriain 2003-02-14 09:54:03 UTC
Does the propsoed patch fix the problem?
Comment 3 bill.haneman 2003-02-14 11:58:04 UTC
thanks Padraig, I think this is the right thing to do; please commit!

[though it's normal to have to dup a CORBA string if you want to
persist it, we don't really want to expose the CORBA-ness of this
value so making it an alloc'd string makes the most sense.  We
couldn't really have made the return const AFAICS]
Comment 4 padraig.obriain 2003-02-14 13:43:19 UTC
Patch committed to CVS HEAD.
Comment 5 remus draica 2003-03-05 14:37:39 UTC
Padraig, in your patch you used g_strdup. That means that g_free must
be called to free allocated memory.
To be consistent with other at-spi functions which returns gchar*
SPI_freeString must be called on returned value.

If this functions is called application which do that crashes.
Comment 6 bill.haneman 2003-03-05 14:59:12 UTC
Certainly using CORBA_string_dup in place of g_strdup (which is indeed
wrong, sorry about that) would make this problem go away, but I am a
little surprised that it's necessary, since the string is already
coming from a demarshalled CORBA value.  

I think my occasional fuzzyheadedness about CORBA lifecycle stuff has
bitten us here; it seems that the CORBA demashalled value get freed by
the CORBA mechanism when we exit the method call.  So if the client is
expected to free the result, we need to CORBA_string_dup the value. 
But I am still unclear on exactly why this is true, since similar
duplication is not required for similar calls such as
AccessibleText_getText.  I think it has to do with the fact the the
event itself (containing the string stuff as internal data) is getting
freed, which results in a free of the internal data; therefore we need
to duplicate it before doing a client-side explicit 'CORBA_free' on
the string.

[SPI_freeString () is really just a wrapper around CORBA_free]

Comment 7 padraig.obriain 2003-03-05 16:53:15 UTC
Created attachment 14793 [details] [review]
New patch
Comment 8 padraig.obriain 2003-03-05 16:53:45 UTC
Is the new patch the correct fix?
Comment 9 bill.haneman 2003-03-05 17:01:41 UTC
I think so, but then again I got it wrong last time :-)
Comment 10 padraig.obriain 2003-03-05 17:14:18 UTC
Created attachment 14795 [details] [review]
Updated patch
Comment 11 padraig.obriain 2003-03-05 17:15:23 UTC
I propose to apply the updated patch as it confirms that crash does
not occur.
Comment 12 bill.haneman 2003-03-05 17:19:52 UTC
thanks Padraig, go ahead and apply!
Comment 13 padraig.obriain 2003-03-05 17:25:45 UTC
Applied patch to CVS HEAD.