orcbytecode: Fix parsing of 32 bit values from bytecode as well
authorTim-Philipp Müller <tim@centricular.net>
Mon, 19 Aug 2013 17:12:21 +0000 (18:12 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 19 Aug 2013 17:15:21 +0000 (18:15 +0100)
The shift by 24 bits has to be casted as well, otherwise we
shift into the sign bit which causes undefined behaviour.

See https://bugzilla.gnome.org/show_bug.cgi?id=698520

orc/orcbytecode.c

index 816d154..f568e14 100644 (file)
@@ -349,9 +349,9 @@ orc_bytecode_parse_get_uint32 (OrcBytecodeParse *parse)
 {
   orc_uint32 value;
   value = orc_bytecode_parse_get_byte (parse);
-  value |= orc_bytecode_parse_get_byte (parse) << 8;
-  value |= orc_bytecode_parse_get_byte (parse) << 16;
-  value |= orc_bytecode_parse_get_byte (parse) << 24;
+  value |= ((orc_uint32)orc_bytecode_parse_get_byte (parse)) << 8;
+  value |= ((orc_uint32)orc_bytecode_parse_get_byte (parse)) << 16;
+  value |= ((orc_uint32)orc_bytecode_parse_get_byte (parse)) << 24;
   return value;
 }