[glom] PyGlomRelatedRecord: Initialize m_document and check it for null.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] PyGlomRelatedRecord: Initialize m_document and check it for null.
- Date: Wed, 3 Dec 2014 07:47:10 +0000 (UTC)
commit 2be01b1b58c5eb49c9563c4f4e42712ca3cc2ce2
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Dec 3 08:46:18 2014 +0100
PyGlomRelatedRecord: Initialize m_document and check it for null.
Found by Coverity Scan.
glom/libglom/python_embed/py_glom_relatedrecord.cc | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/glom/libglom/python_embed/py_glom_relatedrecord.cc
b/glom/libglom/python_embed/py_glom_relatedrecord.cc
index f4ae40a..053b6f1 100644
--- a/glom/libglom/python_embed/py_glom_relatedrecord.cc
+++ b/glom/libglom/python_embed/py_glom_relatedrecord.cc
@@ -35,6 +35,7 @@ namespace Glom
{
PyGlomRelatedRecord::PyGlomRelatedRecord()
+: m_document(0)
{
}
@@ -67,6 +68,13 @@ boost::python::object PyGlomRelatedRecord::getitem(const boost::python::object&
const Glib::ustring related_table = m_relationship->get_to_table();
+ if(!m_document)
+ {
+ std::cerr << G_STRFUNC << ": m_document is null. field: " << field_name << ", table:" <<
m_relationship->get_to_table() << std::endl;
+ PyErr_SetString(PyExc_IndexError, "m_document is null");
+ return boost::python::object();
+ }
+
//Check whether the field exists in the table.
sharedptr<const Field> field = m_document->get_field(m_relationship->get_to_table(), field_name);
if(!field)
@@ -153,6 +161,13 @@ boost::python::object PyGlomRelatedRecord::generic_aggregate(const std::string&
{
const Glib::ustring related_table = m_relationship->get_to_table();
+ if(!m_document)
+ {
+ std::cerr << G_STRFUNC << ": m_document is null. field: " << field_name << ", table:" << related_table
<< std::endl;
+ PyErr_SetString(PyExc_RuntimeError, "m_document is null");
+ return boost::python::object();
+ }
+
//Check whether the field exists in the table.
sharedptr<Field> field = m_document->get_field(m_relationship->get_to_table(), field_name);
if(!field)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]