#976728 gnote: Use of an uninitialized variable

Package:
gnote
Source:
gnote
Description:
desktop note taking program using Wiki style links
Submitter:
Davide Prina
Date:
2020-12-07 13:39:03 UTC
Severity:
normal
Tags:
#976728#5
Date:
2020-12-07 13:34:29 UTC
From:
To:
$ valgrind --leak-check=full  --num-callers=50 --show-reachable=no --show-possibly-lost=no --track-origins=yes --trace-children=yes gnote
[...]
==35493== Conditional jump or move depends on uninitialised value(s)
==35493==    at 0x1A8DBD: gnote::sync::SyncManager::update_sync_action() (syncmanager.cpp:434)
[...]
==35493==  Uninitialised value was created by a heap allocation
==35493==    at 0x4838DEF: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==35493==    by 0x171697: gnote::Gnote::common_init() (gnote.cpp:153)
[...]

as you can see at gnote.cpp:153
m_sync_manager = new sync::SyncManager(*this, default_note_manager());

m_sync_manager is allocated, but at syncmanager.cpp:434
if(timeoutPref != m_autosync_timeout_pref_minutes) {

m_autosync_timeout_pref_minutes is used before it is initialized.

I propose a simple patch that initialize m_autosync_timeout_pref_minutes
with values 1 in the SyncManager constructor. I don't know if this
values can be correct or it is too small.

I tested the patch on my system.

I attach the patch

Ciao
Davide