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

fix: null pointer deref on col #943

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

sangshuduo
Copy link
Contributor

@sangshuduo sangshuduo commented Aug 8, 2023

The defect is detected by coverity scan. The detailed info is following:

*** CID 416530:  Null pointer dereferences  (FORWARD_NULL)
/root/pxiao/TDengine/contrib/geos/capi/geos_ts_c.cpp: 2075 in GEOSGeom_releaseCollection_r::[lambda() (instance 1)]::operator ()() const()
2069                 GeometryCollection *col = dynamic_cast<GeometryCollection*>(collection);
2070                 if (!col) {
2071                     handle->ERROR_MESSAGE("Parameter collection of GEOSGeom_releaseCollection_r must not be a collection");
2072                 }
2073     
2074                 // Early exit on empty/null input
>>>     CID 416530:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "col" to "getNumGeometries", which dereferences it. (The dereference happens because this is a virtual function call.)
2075                 *ngeoms = static_cast<unsigned int>(col->getNumGeometries());
2076                 if (!col || *ngeoms == 0) {
2077                     return static_cast<Geometry**>(nullptr);
2078                 }
2079     
2080                 std::vector<std::unique_ptr<Geometry>> subgeoms = col->releaseGeometries();

@dr-jts dr-jts added the Bug label Aug 9, 2023
@dr-jts
Copy link
Contributor

dr-jts commented Aug 9, 2023

Thanks!

@dr-jts dr-jts merged commit 356a18e into libgeos:main Aug 9, 2023
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants