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 584832 - Duplicate the exec string returned by gtk_recent_info_get_application_info
Duplicate the exec string returned by gtk_recent_info_get_application_info
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkRecent
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
Emmanuele Bassi (:ebassi)
Depends on:
Blocks:
 
 
Reported: 2009-06-04 14:47 UTC by Rob Bradford
Modified: 2009-06-15 21:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix bug (1.05 KB, patch)
2009-06-04 14:51 UTC, Rob Bradford
rejected Details | Review
Fix the documentation in gtk_recent_info_get_application_info() (2.44 KB, patch)
2009-06-11 20:05 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Rob Bradford 2009-06-04 14:47:57 UTC
gtk_recent_info_get_application_info doesn't g_strdup the string it returns as the executable path despite documenting that you need to g_free it. (whoopsie ;-)


Patch incoming.
Comment 1 Rob Bradford 2009-06-04 14:51:07 UTC
Created attachment 135945 [details] [review]
Patch to fix bug
Comment 2 Matthias Clasen 2009-06-06 00:00:30 UTC
Hmm, might be simpler to just fix the docs ?

Also, I'm dubious what 

 * If the command line contains any escape characters defined inside the
 * storage specification, they will be expanded.

is referring to.


Ebassi ?
Comment 3 Rob Bradford 2009-06-07 14:17:04 UTC
Hhm. You can't just fix the docs to say it doesn't duplicate because people will have written code that expects the behaviour according to the published API.
Comment 4 Matthias Clasen 2009-06-08 01:12:00 UTC
Any such code will crash when it frees the non-duplicated string, so I doubt there is too much affected code out there...
Comment 5 Rob Bradford 2009-06-09 17:13:23 UTC
Reasonable point. Emmanuele, what would you like me to do?
Comment 6 Emmanuele Bassi (:ebassi) 2009-06-09 22:50:40 UTC
since the application information is stored inside the RecentInfo and it's guaranteed to be valid until the RecentInfo is valid, then copying should be superfluous. at least, that was (as far as I remember) the line of reasoning I followed - I probably just forgot to update the documentation.

for that, and for Matthias comment, I'd say that the documentation should be fixed to say that "the app_exec string is owned by the RecentInfo structure and should not be modified or freed".
Comment 7 Emmanuele Bassi (:ebassi) 2009-06-09 22:53:23 UTC
as a side node: hopefully I'll be able to finish the GIO integration, and we'll have a gtk_recent_info_get_g_app_info() returning a GAppInfo instead -- which should make gtk_recent_info_get_app_info() redundant (and possibly deprecated).
Comment 8 Rob Bradford 2009-06-09 22:57:12 UTC
And you, Emmanuele, would be even more of a super-hero than usual. I'll work on a patch to do the other way, and uhm, fix my code. :-)
Comment 9 Emmanuele Bassi (:ebassi) 2009-06-11 20:05:27 UTC
Created attachment 136355 [details] [review]
Fix the documentation in gtk_recent_info_get_application_info()

The documentation for the function says that the app_exec string
should be freed, but we return a pointer to the internal string
without duplicating it. Since the app_exec string is valid as long
as the GtkRecentInfo is valid the documentation should be fixed
and the out argument should be constified.

Fixes bug:

  Bug 584832 – Duplicate the exec string returned by
               gtk_recent_info_get_application_info
Comment 10 Matthias Clasen 2009-06-15 20:36:14 UTC
Looks good to me