]> git.rm.cloudns.org Git - xonotic/netradiant.git/commit
radiant/preferences: fix memory issue when saving pref
authorAntoine Fontaine <antoine.fontaine@epfl.ch>
Tue, 23 Mar 2021 02:35:37 +0000 (03:35 +0100)
committerAntoine Fontaine <antoine.fontaine@epfl.ch>
Tue, 23 Mar 2021 12:34:41 +0000 (13:34 +0100)
commit832101b1611ef0ae21f2b0bc9854ee8481727b89
tree710e4598761221a2f2d74b089c5d269c696657a4
parenta51e5316431880ab9f6489ebc9e588597d7559ed
radiant/preferences: fix memory issue when saving pref

Valgrind:

```
==80929== Invalid read of size 2
==80929==    at 0x4842B30: memmove (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==80929==    by 0x43618E: char* std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m<char>(char const*, char const*, char*) (stl_algobase.h:386)
==80929==    by 0x435ABC: char* std::__copy_move_a<false, char const*, char*>(char const*, char const*, char*) (stl_algobase.h:404)
==80929==    by 0x436131: char* std::__copy_move_a2<false, char const*, char*>(char const*, char const*, char*) (stl_algobase.h:440)
==80929==    by 0x4359BF: char* std::copy<char const*, char*>(char const*, char const*, char*) (stl_algobase.h:474)
==80929==    by 0x59F28C: Array<char, DefaultAllocator<char> >::Array<char const*>(char const*, char const*) (array.h:86)
==80929==    by 0x59A2A0: Preferences_Save_Safe(PreferenceDictionary&, char const*) (preferences.cpp:207)
==80929==    by 0x59C7A2: Preferences_Save() (preferences.cpp:919)
==80929==    by 0x524500: Radiant_Shutdown() (mainframe.cpp:798)
==80929==    by 0x5223FB: main (main.cpp:654)
==80929==  Address 0xba88510 is 0 bytes after a block of size 64 alloc'd
==80929==    at 0x483B723: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==80929==    by 0x483E017: realloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==80929==    by 0x5272F3F: g_realloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.6)
==80929==    by 0x5290003: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.6)
==80929==    by 0x5290066: g_string_sized_new (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.6)
==80929==    by 0x52905BA: g_string_new (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.6)
==80929==    by 0x59B65A: PrefsDlg::Init() (preferences.cpp:551)
==80929==    by 0x5222A1: main (main.cpp:595)
```
radiant/preferences.cpp