]> granicus.if.org Git - graphviz/commit
get_int_lsb_first: fix undefined behavior in little endian decoding
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 11 Nov 2021 01:27:25 +0000 (17:27 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 17 Nov 2021 01:01:20 +0000 (17:01 -0800)
commitb10f87fc7e4fa19a829aa6bbcf3d147047d3d0db
tree9a041ebbc27b3049c061219797559e23104bd514
parentbad8679e4cbe7909f4e78f8e119f8477e7202f42
get_int_lsb_first: fix undefined behavior in little endian decoding

When this function was called with a byte length of 4 (something that happens
often in this file), the last iteration of this loop would shift an int left by
24. On a platform with 32-bit ints (most platforms Graphviz runs on) this shifts
_into_ the sign bit, something that is undefined behavior with respect to the C
standard.

The changes in this commit make the shift well defined and remove a
-Wsign-conversion warning.
CHANGELOG.md
lib/gvc/gvusershape.c