Opened 9 years ago

Closed 5 years ago

#730 closed patch (fixed)

[Patch] AbstractSTRtree::query segfaults if tree is empty

Reported by: framm Owned by: strk
Priority: minor Milestone: 3.6.4
Component: Core Version: main
Severity: Unassigned Keywords: tree query segfault
Cc:

Description

If no items have been added to a tree, AbstractSTRtree::query() will execute an "intersects" call where one of the arguments is NULL, thus leading to a segmentation violation.

The expected behaviour of query() when querying an empty tree is to simply return an empty result.

Querying an empty tree might sound silly but if you're dealing with a larger system where the tree has been populated in another component you might not always know how many elements have been added, and the tree doesn't offer a public method like "isEmpty" or so.

The attached patch fixes the problem by immediately returning from query() if the tree is empty.

Attachments (1)

query.diff (726 bytes ) - added by framm 9 years ago.
Patch for AbstractSTRtree.cpp

Download all attachments as: .zip

Change History (9)

by framm, 9 years ago

Attachment: query.diff added

Patch for AbstractSTRtree.cpp

comment:1 by strk, 8 years ago

Milestone: 3.4.33.6.1

Ticket retargeted after milestone deleted

comment:2 by strk, 7 years ago

Milestone: 3.6.13.6.2

Ticket retargeted after milestone closed

comment:3 by strk, 7 years ago

Milestone: 3.6.23.6.3

Ticket retargeted after milestone closed

comment:4 by robe, 6 years ago

Milestone: 3.6.33.6.4
Type: defectpatch

comment:5 by dbaston, 6 years ago

Well, better late than never applying this: https://github.com/libgeos/geos/pull/116

framm, do you want to give your name for the commit log?

comment:6 by Daniel Baston <dbaston@…>, 6 years ago

Resolution: fixed
Status: newclosed

In ae8a2d31/git:

Avoid segfault when querying empty tree

Closes #730
Closes https://github.com/libgeos/geos/pull/116

comment:7 by robe, 6 years ago

Resolution: fixed
Status: closedreopened

Looks like this was only applied to 3.7, were you going to apply to 3.6.4 or you think safer to just keep on 3.7?

comment:8 by Daniel Baston <dbaston@…>, 5 years ago

Resolution: fixed
Status: reopenedclosed

In b0bff6d/git:

Avoid segfault when querying empty tree

Fixes #730

Note: See TracTickets for help on using tickets.