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 582708 - [GST_UTILS] GST_WRITE_* macros could be safer
[GST_UTILS] GST_WRITE_* macros could be safer
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other All
: Normal minor
: 0.10.24
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-05-15 04:22 UTC by Thiago Sousa Santos
Modified: 2009-08-10 23:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thiago Sousa Santos 2009-05-15 04:22:45 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:
Comment 1 David Schleef 2009-05-15 05:04:48 UTC
Correct.  Defines should always look like this:

#define add(a,b) ((a)+(b))

That is, () around each parameter, and () around the entire value.
Comment 2 Sebastian Dröge (slomo) 2009-05-15 05:52:16 UTC
Exactly... would be great if you could prepare a patch for all macros in gstutils.h :)
Comment 3 Thiago Sousa Santos 2009-05-15 18:43:43 UTC
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.