Loading ...
Sorry, an error occurred while loading the content.

Re: [PATCH] (28/?) Remove some possible memory leaks

Expand Messages
  • ZyX
    # HG changeset patch # User ZyX # Date 1369716038 -14400 # Node ID 18fe917c66b253cdd7a8d6e55556738ac1b5e3dc # Parent
    Message 1 of 50 , May 27, 2013
    • 0 Attachment
      # HG changeset patch
      # User ZyX <kp-pav@...>
      # Date 1369716038 -14400
      # Node ID 18fe917c66b253cdd7a8d6e55556738ac1b5e3dc
      # Parent 6f5c6a9e88bfef3f0bbbbb92e69bc4efaa88452d
      Purge out DICTKEY_CHECK_EMPTY macros

      Where it used to be used it has possible memory leak problem

      diff -r 6f5c6a9e88bf -r 18fe917c66b2 src/if_py_both.h
      --- a/src/if_py_both.h Tue May 28 08:29:42 2013 +0400
      +++ b/src/if_py_both.h Tue May 28 08:40:38 2013 +0400
      @@ -32,15 +32,8 @@

      #define DICTKEY_DECL \
      PyObject *dictkey_todecref = NULL;
      -#define DICTKEY_CHECK_EMPTY(err) \
      - if (*key == NUL) \
      - { \
      - PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
      - return err; \
      - }
      -#define DICTKEY_SET_KEY (key = StringToChars(keyObject, &dictkey_todecref))
      #define DICTKEY_GET(err, decref) \
      - if (!DICTKEY_SET_KEY) \
      + if (!(key = StringToChars(keyObject, &dictkey_todecref))) \
      { \
      if (decref) \
      { \
      @@ -50,7 +43,11 @@
      } \
      if (decref && !dictkey_todecref) \
      dictkey_todecref = keyObject; \
      - DICTKEY_CHECK_EMPTY(err)
      + if (*key == NUL) \
      + { \
      + PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
      + return err; \
      + }
      #define DICTKEY_UNREF \
      Py_XDECREF(dictkey_todecref);

      @@ -4552,7 +4549,7 @@

      while (PyDict_Next(obj, &iter, &keyObject, &valObject))
      {
      - DICTKEY_DECL
      + PyObject *todecref = NULL;

      if (keyObject == NULL || valObject == NULL)
      {
      @@ -4560,16 +4557,21 @@
      return -1;
      }

      - if (!DICTKEY_SET_KEY)
      + if (!(key = StringToChars(keyObject, &todecref)))
      {
      dict_unref(dict);
      return -1;
      }
      - DICTKEY_CHECK_EMPTY(-1)
      + if (*key == NUL)
      + {
      + dict_unref(dict);
      + Py_XDECREF(todecref);
      + return -1;
      + }

      di = dictitem_alloc(key);

      - DICTKEY_UNREF
      + Py_XDECREF(todecref);

      if (di == NULL)
      {
      @@ -4633,31 +4635,37 @@

      while ((keyObject = PyIter_Next(iterator)))
      {
      - DICTKEY_DECL
      -
      - if (!DICTKEY_SET_KEY)
      + PyObject *todecref;
      +
      + if (!(key = StringToChars(keyObject, &todecref)))
      {
      + Py_DECREF(keyObject);
      Py_DECREF(iterator);
      dict_unref(dict);
      - DICTKEY_UNREF
      return -1;
      }
      - DICTKEY_CHECK_EMPTY(-1)
      + if (*key == NUL)
      + {
      + Py_DECREF(keyObject);
      + Py_DECREF(iterator);
      + Py_XDECREF(todecref);
      + dict_unref(dict);
      + return -1;
      + }

      if (!(valObject = PyObject_GetItem(obj, keyObject)))
      {
      Py_DECREF(keyObject);
      Py_DECREF(iterator);
      + Py_XDECREF(todecref);
      dict_unref(dict);
      - DICTKEY_UNREF
      return -1;
      }

      di = dictitem_alloc(key);

      - DICTKEY_UNREF
      -
      Py_DECREF(keyObject);
      + Py_XDECREF(todecref);

      if (di == NULL)
      {

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • ZyX
      You are right, thanks. Should have reread the docs. -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the
      Message 50 of 50 , Jun 1, 2013
      • 0 Attachment
        You are right, thanks. Should have reread the docs.

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.