Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverity: geoit can be end() when dereferenced #4429

Closed
wants to merge 1 commit into from

Conversation

chennes
Copy link
Member

@chennes chennes commented Feb 11, 2021

Coverity has identified a potential bug that this PR seeks to address: in the Sketcher function analyseBlockedGeometry() there is a conditional:

auto geoit = std::find(blockedGeoIds.begin(),blockedGeoIds.end(),c->Second);
if(geoit != blockedGeoIds.end() || onlyblockedGeometry[c->Second]) { // internal alignment geometry found, add to list

and then later on inside that conditional

blockedGeoIds.push_back(*geoit);

However, since the condition is an OR, it is apparently possible that geoit is end(), in which case dereferencing it is illegal. The fix proposed in this PR is to modify the OR to an AND. However, this needs review.

This fix is a joint effort with @hyarion.

@wwmayer
Copy link
Contributor

wwmayer commented Feb 11, 2021

Replace blockedGeoIds.push_back(*geoit); with blockedGeoIds.push_back(c->Second);

@hyarion
Copy link
Contributor

hyarion commented Feb 11, 2021

Just for the record, here's the forum post regarding the proposed fix: https://forum.freecadweb.org/viewtopic.php?p=476886#p476886

@chennes
Copy link
Member Author

chennes commented Feb 12, 2021

Closed in favor of the real fix in #4442

@chennes chennes closed this Feb 12, 2021
@chennes chennes deleted the coveritySketcherBadIterator branch March 8, 2021 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants