#140 ConvertOper string bug

open
nobody
None
5
2011-11-28
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


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks