GNOME Bugzilla – Bug 582708
[GST_UTILS] GST_WRITE_* macros could be safer
Last modified: 2009-08-10 23:28:41 UTC
Please describe the problem: While developing asfmux today I ran over some overflow problems because of the following: GST_WRITE_UINT32_LE (mydata, GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND); however, if I change it to GST_WRITE_UINT32_LE (mydata, (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND)); with aditional parameters, it's all ok. My suggestion is to change the macros to already have this extra parameters to prevent this in future development. I tracked the 'problem' to lines 173-4 of http://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstutils.h Just adding the ( ) around __num should do it, right? Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Correct. Defines should always look like this: #define add(a,b) ((a)+(b)) That is, () around each parameter, and () around the entire value.
Exactly... would be great if you could prepare a patch for all macros in gstutils.h :)
It seems that the other macros in gstutils.h are alright. Just commited a fix for gstutils.h and another one for gstvalue.h Module: gstreamer Branch: master Commit: 69a1a60a871f8f3c5866b07af2c3a785e129d55d URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=69a1a60a871f8f3c5866b07af2c3a785e129d55d Author: Thiago Santos <thiagoss@embedded.ufcg.edu.br> Date: Fri May 15 14:42:48 2009 -0300 [gstutils] Adds more safety to GST_WRITE_* and GST_READ_ macros. Adds safety ( ) to parameters in _GST_PUT and _GST_GET macros. Fixes #582708. Module: gstreamer Branch: master Commit: f2890f46a59505f810750a0ea227de4e682b5ec5 URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=f2890f46a59505f810750a0ea227de4e682b5ec5 Author: Thiago Santos <thiagoss@embedded.ufcg.edu.br> Date: Fri May 15 15:24:40 2009 -0300 [gstvalue] adds safety parenthesis to macros missing them.