Created
August 10, 2020 01:47
-
-
Save rcurtin/b55cf600d01f69e9e02556eeadefb35e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1adc34da2e3f7d3a5c8cb600d5d62cd018f7ca65 Mon Sep 17 00:00:00 2001 | |
From: Ryan Curtin <ryan@ratml.org> | |
Date: Sun, 9 Aug 2020 21:46:05 -0400 | |
Subject: [PATCH 1/3] Fix handling of NULL pointers. | |
--- | |
src/mlpack/core/cereal/pointer_wrapper.hpp | 4 +++- | |
1 file changed, 3 insertions(+), 1 deletion(-) | |
diff --git a/src/mlpack/core/cereal/pointer_wrapper.hpp b/src/mlpack/core/cereal/pointer_wrapper.hpp | |
index 3b3f228d6..36a657940 100644 | |
--- a/src/mlpack/core/cereal/pointer_wrapper.hpp | |
+++ b/src/mlpack/core/cereal/pointer_wrapper.hpp | |
@@ -49,7 +49,9 @@ class pointer_wrapper | |
template<class Archive> | |
void save(Archive& ar, const unsigned int /*version*/) const | |
{ | |
- std::unique_ptr<T> smartPointer = std::make_unique<T>(*this->localPointer); | |
+ std::unique_ptr<T> smartPointer; | |
+ if (this->localPointer != NULL) | |
+ smartPointer = std::make_unique<T>(std::move(*this->localPointer)); | |
ar(CEREAL_NVP(smartPointer)); | |
localPointer = smartPointer.release(); | |
} | |
-- | |
2.28.0.rc1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks 👍