Fix nullptr dereferencing in val_fixtures.cpp
authorAndrey Tuganov <andreyt@google.com>
Wed, 8 Mar 2017 17:06:31 +0000 (12:06 -0500)
committerDavid Neto <dneto@google.com>
Wed, 8 Mar 2017 20:41:46 +0000 (15:41 -0500)
test/val/val_fixtures.cpp

index eb9527c..c72cbf5 100644 (file)
@@ -82,7 +82,8 @@ spv_result_t ValidateBase<T>::ValidateAndRetrieveValidationState(
 
 template <typename T>
 std::string ValidateBase<T>::getDiagnosticString() {
-  return std::string(diagnostic_->error);
+  return diagnostic_ == nullptr ?
+      std::string() : std::string(diagnostic_->error);
 }
 
 template <typename T>
@@ -92,7 +93,7 @@ spv_validator_options ValidateBase<T>::getValidatorOptions() {
 
 template <typename T>
 spv_position_t ValidateBase<T>::getErrorPosition() {
-  return diagnostic_->position;
+  return diagnostic_ == nullptr ? spv_position_t() : diagnostic_->position;
 }
 
 template class spvtest::ValidateBase<bool>;