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 765078 - Gst::Sample::get_caps doesn't reference the returned Glib::RefPtr<Gst::Caps>
Gst::Sample::get_caps doesn't reference the returned Glib::RefPtr<Gst::Caps>
Status: RESOLVED FIXED
Product: gstreamermm
Classification: Bindings
Component: general
1.4.x
Other Linux
: Normal normal
: ---
Assigned To: gstreamermm-maint
gstreamermm-maint
Depends on:
Blocks:
 
 
Reported: 2016-04-15 04:11 UTC by Ben Schleimer
Modified: 2016-04-15 21:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ben Schleimer 2016-04-15 04:11:15 UTC
Hi,
   I was trying to get print out the caps of a sample of a Gst::AppSink to understand what it is giving me and I uncovered a bug (I think):
In the slot for Gst::AppSink::signal_new_sample():
```
using SamplePtr = Glib::RefPtr<Gst::Sample>;
SamplePtr sample = m_app_sink->pull_sample();
ASSERT(sample);
// Use the C++ API
CapsPtr caps = sample->get_caps();
caps->reference();
ASSERT(caps);

// Use the standard API
//  GstCaps* caps = gst_sample_get_caps(sample->gobj());
```

In the C++ wrapped version, if caps->reference() is not used, then it crashes after 10 iterations or so because the object's ref count goes to zero eventually.
If I add caps->reference(), then the ref count stays even.
I think that the bug is in sample.hg where it's not marked as refreturn but I'm not sure.

Cheers
Ben
Comment 1 Ben Schleimer 2016-04-15 04:21:08 UTC
BTW, this is with gstreamermm 1.4.3 and gstreamer 1.6.3
Comment 2 Marcin Kolny (IRC: loganek) 2016-04-15 19:29:35 UTC
Thanks for the report.
I've fixed the problem in master. It will be available in gstreamermm 1.8, which I'm currently working on.

https://git.gnome.org/browse/gstreamermm/commit/?id=1b3fb04a9e3cfe49a8e0f475b0a4046c19c17be9
Comment 3 Ben Schleimer 2016-04-15 21:26:05 UTC
Wow, awesome.
Thank you. I'll start working from master soon.

I have found a couple more issues of the same kind that I'll post up.