Fix uninitialised variables when failing to raw_convert to POD types.
authorCarl Hetherington <cth@carlh.net>
Tue, 8 Mar 2016 22:10:33 +0000 (22:10 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 8 Mar 2016 22:10:33 +0000 (22:10 +0000)
ChangeLog
src/lib/raw_convert.h

index f35e0adbc1505d006641301058b562250eba55e5..d7bae43926e4e857ef814aaa191ec19efe3d8731 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-03-08  Carl Hetherington  <cth@carlh.net>
 
+       * Fix occasional crash when opening the custom
+       colour conversion editor.
+
        * Version 2.7.0 released.
 
 2016-03-08  Carl Hetherington  <cth@carlh.net>
index 96bd7f6335042d71d99f4244c617c935dfc5d2b2..6e55d49cf4802c8930b3eb7e994c8e05f09d8471 100644 (file)
@@ -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;
 }