From 4b7fab6e3dbb7cae32a2e0b66f1b6ca275367126 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 8 Mar 2016 22:10:33 +0000 Subject: [PATCH] Fix uninitialised variables when failing to raw_convert to POD types. --- ChangeLog | 3 +++ src/lib/raw_convert.h | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 878d461a3..e90e81753 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,9 @@ 2016-03-08 Carl Hetherington + * Fix occasional crash when opening the custom + colour conversion editor. + * Version 2.7.0 released. 2016-03-08 Carl Hetherington diff --git a/src/lib/raw_convert.h b/src/lib/raw_convert.h index 96bd7f633..6e55d49cf 100644 --- a/src/lib/raw_convert.h +++ b/src/lib/raw_convert.h @@ -34,7 +34,12 @@ raw_convert (Q v, int precision = 16) s.imbue (std::locale::classic ()); s << std::setprecision (precision); s << v; - P r; + /* If the s >> r below fails to convert anything, we want r to + be left as a defined value. This construct (I believe) achieves + this by setting r to the default value of type P, even if P + is a POD type. + */ + P r = P (); s >> r; return r; } -- 2.30.2