[glom] PyGlomRelated::get_item(): Avoid leaking the PyGlomRelatedRecord.



commit 8800c65104a87cf2137c02943108438b8c2fb058
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Dec 2 19:25:17 2014 +0100

    PyGlomRelated::get_item(): Avoid leaking the PyGlomRelatedRecord.
    
    Found by Coverity Scan.

 glom/libglom/python_embed/py_glom_related.cc |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/glom/libglom/python_embed/py_glom_related.cc b/glom/libglom/python_embed/py_glom_related.cc
index 2b2acd9..d240f05 100644
--- a/glom/libglom/python_embed/py_glom_related.cc
+++ b/glom/libglom/python_embed/py_glom_related.cc
@@ -66,11 +66,6 @@ boost::python::object PyGlomRelated::getitem(const boost::python::object& cppite
         PyGlomRelated::type_map_relationships::const_iterator iterFind = m_map_relationships.find(key);
         if(iterFind != m_map_relationships.end())
         {
-          //Return a new RelatedRecord:
-          PyGlomRelatedRecord* pyRelatedRecord = new PyGlomRelatedRecord();
-
-          //Fill it.
-
           //Get the value of the from_key in the parent record.
           sharedptr<Relationship> relationship = iterFind->second;
           const Glib::ustring from_key = relationship->get_from_field();
@@ -89,6 +84,8 @@ boost::python::object PyGlomRelated::getitem(const boost::python::object& cppite
               sharedptr<const Field> from_key_field = record->m_document->get_field(record->m_table_name, 
from_key);
               if(from_key_field)
               {
+                //Return a new RelatedRecord:
+                PyGlomRelatedRecord* pyRelatedRecord = new PyGlomRelatedRecord();
                 pyRelatedRecord->set_relationship(iterFind->second, from_key_value, record->m_document);
 
                 //Store it in the cache:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]