[ quantlib-Bugs-1966376 ] Bug: isInSubset

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ quantlib-Bugs-1966376 ] Bug: isInSubset

SourceForge.net
Bugs item #1966376, was opened at 2008-05-18 01:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=1966376&group_id=12740

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug: isInSubset

Initial Comment:
Hello,

the function isInSubset in ql/models/marketmodels/utilities.cpp crashes in some cases.

Subset loop:

while (true) {
  subsetElement = subset[j];
  result[i] = false;
  if (setElement < subsetElement) break;
  if (setElement == subsetElement) {
    result[i] = true;
    break;
  }
  if (j > dimsubSet-1) break;
  ++j;
}

The largest allowed j in the line with the break is j==dimsubSet-1. In the next line j is increased by 1 and we have j==dimsubSet. The next statement at the beginning of the while-loop will exceed the array-boundary:
subsetElement = subset[j].

I think a greater or equal would be a solution:
if (j >= dimsubSet-1) break;

Kind regards
Jan van Heys

email: [hidden email]


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=1966376&group_id=12740

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev