After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729195 - videotestsrc: undefined behaviour in left-shift
videotestsrc: undefined behaviour in left-shift
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal minor
: 1.3.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-29 14:27 UTC by Luis de Bethencourt
Modified: 2014-05-01 20:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix by typecasting value before left-shifting (1.12 KB, patch)
2014-04-29 14:28 UTC, Luis de Bethencourt
committed Details | Review

Description Luis de Bethencourt 2014-04-29 14:27:09 UTC
In line 1137 of videotestsrc.c there is a left-shift by 24 applied to a guint8. The behaviour is undefined.
Comment 1 Luis de Bethencourt 2014-04-29 14:28:07 UTC
Created attachment 275426 [details] [review]
fix by typecasting value before left-shifting
Comment 2 Luis de Bethencourt 2014-04-29 15:03:51 UTC
The two options were changing the type to guint32 in vts_color_struct or casting to guint32 when necessary. This struct has more uses and could potentially be hundreds of instances. So type casting is less intrusive.

The problem, as slomo reminded me, is that a guint8 gets promoted to an int (gint32). Which means there could be sign bit flipping happening without the type casting.

Pushed the patch:
954db90918db5532463612a0ec6a891e463a57b7