diff options
author | Philipp Stephani <phst@google.com> | 2019-12-23 21:24:37 +0100 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2019-12-23 21:27:23 +0100 |
commit | 00c9949158e82fc93135ac62013bee1c08161649 (patch) | |
tree | e4905c8be7020ad36d54528a3b10d8cbab79cd0b /src/macfont.m | |
parent | 17c19817f7f4ec918a3a9bb3c957b1aa0463da82 (diff) | |
download | emacs-00c9949158e82fc93135ac62013bee1c08161649.tar.gz |
Remove some undefined behavior related to left shifts.
Found by UBSan.
* src/nsfns.m (ns_set_foreground_color, ns_set_background_color):
* src/nsimage.m (getPixelAtX:Y:):
* src/nsterm.m (ns_color_index_to_rgba): Add explicit casts to avoid
undefined behavior when left-shifting beyond the bounds of the int
type.
* src/macfont.m (METRICS_VALUE): Add explicit casts to avoid undefined
behavior when left-shifting a negative value.
Diffstat (limited to 'src/macfont.m')
-rw-r--r-- | src/macfont.m | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/macfont.m b/src/macfont.m index 7170e801407..fa4a818efa6 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -1126,7 +1126,8 @@ struct macfont_metrics }; #define METRICS_VALUE(metrics, member) \ - (((metrics)->member##_high << 8) | (metrics)->member##_low) + ((int) (((unsigned int) (metrics)->member##_high << 8) \ + | (metrics)->member##_low)) #define METRICS_SET_VALUE(metrics, member, value) \ do {short tmp = (value); (metrics)->member##_low = tmp & 0xff; \ (metrics)->member##_high = tmp >> 8;} while (0) |