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 783978 - utils/registrychunks: Fix leaks in failed cases
utils/registrychunks: Fix leaks in failed cases
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other Mac OS
: Normal normal
: 1.12.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-06-20 01:01 UTC by Heekyoung Seo
Modified: 2017-06-20 07:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
utils/registrychunk: Fix leaks in failed cases (1.18 KB, patch)
2017-06-20 01:04 UTC, Heekyoung Seo
none Details | Review
registrychunk: Fix leak in failed case of reading plugin dependency string (748 bytes, patch)
2017-06-20 07:29 UTC, Heekyoung Seo
committed Details | Review
utils: Fix leak in failed case of regression overflow checking (812 bytes, patch)
2017-06-20 07:32 UTC, Heekyoung Seo
committed Details | Review

Description Heekyoung Seo 2017-06-20 01:01:45 UTC
[Case 1] gstutils.c

Regression overflow checking failed case in gst_calculate_linear_regression function, newx is not freed before return FALSE.

  /* have to do this precisely otherwise the results are pretty much useless.
   * should guarantee that none of these accumulators can overflow */

  /* quantities on the order of 1e10 to 1e13 -> 30-35 bits;
   * window size a max of 2^10, so
   this addition could end up around 2^45 or so -- ample headroom */
  for (i = j = 0; i < n; i++, j += 2) {
    /* Just in case assumptions about headroom prove false, let's check */
    if ((newx[j] > 0 && G_MAXUINT64 - xbar <= newx[j]) ||
        (newy[j] > 0 && G_MAXUINT64 - ybar <= newy[j])) {
      GST_CAT_WARNING (GST_CAT_CLOCK,
          "Regression overflowed in clock slaving! xbar %"
          G_GUINT64_FORMAT " newx[j] %" G_GUINT64_FORMAT " ybar %"
          G_GUINT64_FORMAT " newy[j] %" G_GUINT64_FORMAT, xbar, newx[j], ybar,
          newy[j]);
+      if (temp == NULL && n > 64)
+        g_free (newx);
       return FALSE;
     }


[Case 2] gstregistrychunk.c
unpack_string failed case in gst_registry_chunks_load_plugin_dep_strv function, arr is not freed before return.

static gchar **
gst_registry_chunks_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
{
  gchar **arr;

  if (n == 0)
    return NULL;

  arr = g_new0 (gchar *, n + 1);
  while (n > 0) {
    unpack_string (*in, arr[n - 1], end, fail);
    --n;
  }
  return arr;
 fail:
   GST_INFO ("Reading plugin dependency strings failed");
+  g_strfreev (arr);
   return NULL;
 }
Comment 1 Heekyoung Seo 2017-06-20 01:04:35 UTC
Created attachment 354074 [details] [review]
utils/registrychunk: Fix leaks in failed cases
Comment 2 Sebastian Dröge (slomo) 2017-06-20 06:31:57 UTC
Comment on attachment 354074 [details] [review]
utils/registrychunk: Fix leaks in failed cases

Please attach this as two separate patches to this bug, thanks!
Comment 3 Heekyoung Seo 2017-06-20 07:29:49 UTC
Created attachment 354079 [details] [review]
registrychunk: Fix leak in failed case of reading plugin dependency string
Comment 4 Heekyoung Seo 2017-06-20 07:32:26 UTC
Created attachment 354080 [details] [review]
utils: Fix leak in failed case of regression overflow checking
Comment 5 Heekyoung Seo 2017-06-20 07:35:30 UTC
(In reply to Sebastian Dröge (slomo) from comment #2)
> Comment on attachment 354074 [details] [review] [review]
> utils/registrychunk: Fix leaks in failed cases
> 
> Please attach this as two separate patches to this bug, thanks!

Dear Sabastian,

I attached as two separate patches to this bug again. 
Thank you.
Comment 6 Sebastian Dröge (slomo) 2017-06-20 07:56:57 UTC
Attachment 354079 [details] pushed as d32afe3 - registrychunk: Fix leak in failed case of reading plugin dependency string
Attachment 354080 [details] pushed as c30c39b - utils: Fix leak in failed case of regression overflow checking