Menu

#140 ConvertOper string bug

None
closed-out-of-date
nobody
None
5
2019-01-02
2011-11-28
Dave Blob
No

ConvertOper::operator std::string() const tries to access a temporary variable after it is destroyed (xString becomes a reference to the deleted variable xTemp). Here's a fix:

ConvertOper::operator std::string() const {
const OPER *xString;

if (oper_->xltype == xltypeStr) {
xString = oper_;
} else {
Xloper xTemp;
Excel(xlCoerce, &xTemp, 2, oper_, TempInt(xltypeStr));
xString = &xTemp;
}

return strConv(xString);
}

Could be replaced with:

ConvertOper::operator std::string() const {
const OPER *xString;

if (oper_->xltype == xltypeStr) {
xString = oper_;
return strConv(xString);
} else {
Xloper xTemp;
Excel(xlCoerce, &xTemp, 2, oper_, TempInt(xltypeStr));
xString = &xTemp;
return strConv(xString);
}
}

Discussion

  • Luigi Ballabio

    Luigi Ballabio - 2017-12-05

    If this is still relevant, may you open an issue at https://github.com/eehlers/QuantLibXL?

     
  • Luigi Ballabio

    Luigi Ballabio - 2019-01-02
    • status: open --> closed-out-of-date
    • Group: -->
     

Log in to post a comment.

MongoDB Logo MongoDB