diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-05-30 00:26:04 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-05-30 00:26:04 +0000 |
commit | 732d940744c667d7aae82db0fd7947939a0048f8 (patch) | |
tree | 79cf0c4256eb18948e666d7a74758596b6bcf0ce /riscos/wimp.c | |
parent | 5404e91fcdfc831e5d50618d0082243382e11f1f (diff) | |
download | netsurf-732d940744c667d7aae82db0fd7947939a0048f8.tar.gz netsurf-732d940744c667d7aae82db0fd7947939a0048f8.tar.bz2 |
Stop ro_gui_get_icon_string() returning a pointer to a location on the stack.
Make explicit the semantics that strings returned from this call are transient
and will be invalidated by subsequent calls.
svn path=/trunk/netsurf/; revision=7645
Diffstat (limited to 'riscos/wimp.c')
-rw-r--r-- | riscos/wimp.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/riscos/wimp.c b/riscos/wimp.c index fa69dc845..71443afb4 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -220,12 +220,18 @@ void ro_gui_force_redraw_icon(wimp_w w, wimp_i i) * \param i icon handle * \return NUL terminated string in icon * + * If the icon contains direct text then the returned data will + * be invalidated by the next call to this function. Therefore, + * all client calls to this function must either copy the string or + * ensure that this function is not called again until they are + * finished with the string data returned. + * * \todo this doesn't do local encoding -> UTF-8 to match what is done in * ro_gui_set_icon_string. */ const char *ro_gui_get_icon_string(wimp_w w, wimp_i i) { - wimp_icon_state ic; + static wimp_icon_state ic; os_error *error; char *itext; @@ -238,12 +244,11 @@ const char *ro_gui_get_icon_string(wimp_w w, wimp_i i) warn_user("WimpError", error->errmess); return NULL; } - itext = (ic.icon.flags & wimp_ICON_INDIRECTED) ? - ic.icon.data.indirected_text.text - : - ic.icon.data.text; + itext = (ic.icon.flags & wimp_ICON_INDIRECTED) + ? ic.icon.data.indirected_text.text : ic.icon.data.text; /* Guarantee NUL termination. */ itext[ro_gui_strlen(itext)] = '\0'; + return itext; } |