From 9d8b0addf94c86f224093bb1ca66ebe18494ff7c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 6 Oct 2015 10:15:38 +0100 Subject: Correctly copy preferences When just assigning one structure to the other we copy the string pointers. If we then modify those strings in the copy, we happily free the strings of the original. And then resetting the preferences equally happily reused those strings, pointing to long since freed memory. I think what I did now is excessive for the current use case in that it copies a ton of strings that are unset in the default_prefs. But I figured this is a rarely used function and I might as well do it correctly. Also, once we implement multi user support with per user preferences we will be copying completely populated preferences around (at least that's my guess). Fixes #940 Signed-off-by: Dirk Hohndel --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 6c5e16928..7807b20df 100644 --- a/main.cpp +++ b/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char **argv) git_libgit2_init(); #endif setup_system_prefs(); - prefs = default_prefs; + copy_prefs(&default_prefs, &prefs); fill_profile_color(); parse_xml_init(); taglist_init_global(); -- cgit v1.2.3-70-g09d2