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>
Thu, 10 Mar 2016 17:44:13 +0000 (17:44 +0000)
ChangeLog
src/lib/raw_convert.h

index 878d461a30992eab3d7f09473234d4adf80e4fd2..e90e817539761c07798191f4af3cfc1de568c5fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
 
 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;
 }