Skip to content

Commit bbb1833

Browse files
pcaspersjenkins
authored andcommitted
QPR-11984 fix
1 parent b4a9fb4 commit bbb1833

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

QuantExt/qle/math/randomvariable.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,15 @@ RandomVariable::RandomVariable(const Size n, const Real value, const Real time)
317317

318318
RandomVariable::RandomVariable(const Filter& f, const Real valueTrue, const Real valueFalse, const Real time) {
319319
if (!f.initialised()) {
320+
data_ = nullptr;
320321
clear();
321322
return;
322323
}
323324
n_ = f.size();
324-
if (f.deterministic())
325+
if (f.deterministic()) {
326+
data_ = nullptr;
325327
setAll(f.at(0) ? valueTrue : valueFalse);
326-
else {
328+
} else {
327329
constantData_ = 0.0;
328330
deterministic_ = false;
329331
data_ = new double[n_];
@@ -340,6 +342,8 @@ RandomVariable::RandomVariable(const QuantLib::Array& array, const Real time) {
340342
if (n_ != 0) {
341343
data_ = new double[n_];
342344
std::memcpy(data_, array.begin(), n_ * sizeof(double));
345+
} else {
346+
data_ = nullptr;
343347
}
344348
constantData_ = 0.0;
345349
}

0 commit comments

Comments
 (0)