diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-03-08 22:10:33 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-03-08 22:10:33 +0000 |
| commit | e77358c6c62130caa336e075bee76c46f1f3983f (patch) | |
| tree | 5b97aff88fd204059a12e5d7a45639509210a0fb | |
| parent | 711c624a1eea6299a1587aee4edce1cd8d35a286 (diff) | |
Fix uninitialised variables when failing to raw_convert to POD types.
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | src/lib/raw_convert.h | 7 |
2 files changed, 9 insertions, 1 deletions
@@ -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> 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; } |
