Skip to content
Commit 3310efe1 authored by Oliver Hiorns's avatar Oliver Hiorns Committed by Fushan Wen
Browse files

fix that UB occurs if Klipper is instantiated twice

We relied on a static variable "firstrun" to track whether certain
variables were uninitialised early on in the lifetime of Klipper
objects, allowing us to avoid using them in their uninitialised state.

Unfortunately static really isn't correct for this role, since we want
to know if it's the first call of the function in this instance, not in
the whole program. If 2 instances of Klipper are created in one runtime,
the static bool firstrun is never reset, so we end up using these
uninitialised variables, leading to UB which can erase the clipboard
history at startup.

Normally this isn't an issue because we only create one instance per
program run, but this is not true in one of Klipper's tests, which
exposed the problem when combined with the previous commit. So, this
fixes a bug which has never affected Klipper from a user PoV, but
causes a test failure.
parent 7af58d7a
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment