[libxml++] Document: Test for nullptr in a constructor
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml++] Document: Test for nullptr in a constructor
- Date: Thu, 7 Jan 2016 09:00:18 +0000 (UTC)
commit fa1ca3e3a02d78edcd0269fe9cde629af9a9af27
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Thu Jan 7 09:54:14 2016 +0100
Document: Test for nullptr in a constructor
In Document(_xmlDoc* doc), throw an exception if doc==nullptr.
libxml++/document.cc | 3 +++
libxml++/document.h | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/libxml++/document.cc b/libxml++/document.cc
index be1ed2f..acd1fe3 100644
--- a/libxml++/document.cc
+++ b/libxml++/document.cc
@@ -179,6 +179,9 @@ Document::Document(const Glib::ustring& version)
Document::Document(xmlDoc* doc)
: impl_(doc)
{
+ if (!impl_)
+ throw internal_error("xmlDoc pointer cannot be nullptr");
+
impl_->_private = this;
}
diff --git a/libxml++/document.h b/libxml++/document.h
index 90ffaa4..5d4ba60 100644
--- a/libxml++/document.h
+++ b/libxml++/document.h
@@ -85,6 +85,7 @@ public:
* The created xmlpp::Document takes ownership of the xmlDoc.
* When the Document is deleted, so is the xmlDoc and all its nodes.
* @param doc A pointer to an xmlDoc struct. Must not be <tt>nullptr</tt>.
+ * @throws xmlpp::internal_error If @a doc is <tt>nullptr</tt>.
*/
explicit Document(_xmlDoc* doc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]