[Geany-devel] configuration save: utils_build_path?
elextr at xxxxx
Sun Apr 10 00:22:36 UTC 2011
On 10 April 2011 03:48, Dimitar Zhekov <dimitar.zhekov at gmail.com> wrote:
> What is the reason for configuration_save() and
> configuration_save_default_session() to use g_strconcat() instead of
> utils_build_path()? Some internal function calls utils_build_path(),
The problem is that utils_build_path is *waaaaay* unsafe, it re-uses a
single buffer so it can't be called again before the caller has
finished with the result, unless the caller copies the result.
It should only be used where the returned string is finished with or
copied before any calls to other functions. It should never be used
anywhere that a caller or callee might use it.
utils_build_path is really a bomb waiting to explode in someone's face
(well code anyway :-). It shouldn't be a general util, either it
should be made safe or if some part of Geany uses enough paths that it
really is a material overhead to allocate and deallocate buffers then
it should be made a local function there, not a general util.
The configuration_save* functions are called from lots of places, if
any of them have used utils_build_path then configuration_save* can't,
so best they don't.
> E-gards: Jimmy
> Geany-devel mailing list
> Geany-devel at uvena.de
More information about the Devel