#254 fix memory leak in perl.so

trunk
closed-accepted
modules (179)
5
2013-01-15
2013-01-02
bratner
No

fixes perl_exec2() in perlfunc.c. The message object that is passed to the perl-script
was left hanging after every call to perl_exec() in the opensips script.

Moved the declaration of OpenSIPS::Message object to the SAVETMPS/FREETMPS
segment so it will be freed before the function returns.

Tested by using Devel::Gladiator.

Discussion

  • bratner
    bratner
    2013-01-02

    --- modules/perl/perlfunc.c (revision 9540)
    +++ modules/perl/perlfunc.c (working copy)
    @@ -127,14 +127,16 @@
    return -1;
    }

    - m = sv_newmortal();
    - sv_setref_pv(m, "OpenSIPS::Message", (void *)_msg);
    - SvREADONLY_on(SvRV(m));

    ENTER; /* everything created after here */
    SAVETMPS; /* ...is a temporary variable. */
    PUSHMARK(SP); /* remember the stack pointer */
    +
    + m = sv_newmortal(); /* create a mortal SV to be killed on FREETMPS */
    + sv_setref_pv(m, "OpenSIPS::Message", (void *)_msg); /* bless the message with a class */
    + SvREADONLY_on(SvRV(m)); /* set the content of m to be readonly */
    +
    XPUSHs(m); /* Our reference to the stack... */

    if (mystr)
    @@ -151,6 +153,5 @@
    PUTBACK;
    FREETMPS; /* free that return value */
    LEAVE; /* ...and the XPUSHed "mortal" args.*/
    -
    return retval;
    }

     
  • bratner
    bratner
    2013-01-02

    • labels: --> modules
    • milestone: --> trunk
     
  • bratner
    bratner
    2013-01-02

    patch

     
  • Fix uploaded on SVN trunk, 1.8 and 1.7 .

    Thanks and regards,
    Bogdan

     
    • assigned_to: nobody --> bogdan_iancu
    • status: open --> closed-accepted