validate-report: Make the ref / unref functions safer.

This commit is contained in:
Mathieu Duponchelle 2014-10-01 15:50:11 +02:00 committed by Mathieu Duponchelle
parent 1fcaf8918f
commit b8ac717297

View file

@ -432,6 +432,8 @@ gst_validate_report_new (GstValidateIssue * issue,
void void
gst_validate_report_unref (GstValidateReport * report) gst_validate_report_unref (GstValidateReport * report)
{ {
g_return_if_fail (report != NULL);
if (G_UNLIKELY (g_atomic_int_dec_and_test (&report->refcount))) { if (G_UNLIKELY (g_atomic_int_dec_and_test (&report->refcount))) {
g_free (report->message); g_free (report->message);
g_slice_free (GstValidateReport, report); g_slice_free (GstValidateReport, report);
@ -441,6 +443,8 @@ gst_validate_report_unref (GstValidateReport * report)
GstValidateReport * GstValidateReport *
gst_validate_report_ref (GstValidateReport * report) gst_validate_report_ref (GstValidateReport * report)
{ {
g_return_val_if_fail (report != NULL, NULL);
g_atomic_int_inc (&report->refcount); g_atomic_int_inc (&report->refcount);
return report; return report;