Memory leak on _default () of union

Daniel Laügt daniel.laugt at wallstreetsystems.com
Tue Mar 22 13:31:06 GMT 2016


Hello,



There is a memory leak caused by the following revision:

http://sourceforge.net/p/omniorb/svn/5934/



_default() of union should release its member.



test.idl:

module Test

{

  struct Money

  {

    double m;

  };



  union nullable_money switch (boolean) { case TRUE: Money v; };

};



test.cc:

#include <idl/Test.h>

int main ()

{

  Test::Money a;

  a.m = 1;



  Test::nullable_money b;

  b.v (a);

  b._default (); // memory leak



  return 0;

}



test.h:

    void v (const Money& _value) {

      _release_member();

      _pd__initialised = 1;

      _pd__d = 1;

      _pd__default = 0;

      _pd_v = new Money(_value);

    }

    void _default()

    {

      _pd__initialised = 1;

      _pd__d = 0;

      _pd__default = 1;

    }

    ~nullable_money() {

      _release_member();

    }

    void _release_member () {

      if (!_pd__initialised)

        return;



      switch(_pd__d) {

        case 1:



          delete _pd_v;





          break;



        default:



          break;





      }

      _pd__initialised = false;

    }



Regards,

Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20160322/65c53655/attachment.html>


More information about the omniORB-list mailing list