gnucash maint: Provide static strings for gnc_userdata_home and gnc_userconfig_home.
John Ralls
jralls at code.gnucash.org
Thu Apr 11 20:38:35 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/c091197f (commit)
from https://github.com/Gnucash/gnucash/commit/6e7a4ccc (commit)
commit c091197f572a701cb2ecc81c40fe47bbd41f59aa
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Apr 11 17:25:40 2019 -0700
Provide static strings for gnc_userdata_home and gnc_userconfig_home.
On Windows boost::filesystem::path's string() produces a string
that goes out of scope with the function in which it's called, so
returning its c_str() ptr yields freed memory, usually full of garbage.
This has an interesting side effect in gnc-file.c's check_file_path():
Since the memory is freed, g_path_get_dirname() reuses it after an
iteration or two, writing its result into the same address. The
following strcmp naturally returns 0 because it's comparing two
instances of the same ptr, so check_file_path falsely reports that
the proposed save path is in GNC_USERDATA_DIR.
Summary of changes:
libgnucash/core-utils/gnc-filepath-utils.cpp | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
More information about the gnucash-patches
mailing list