Skip to content

Fixed segfaults in poly __new__ and pgPolygon_FromObject #186

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

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

itzpr3d4t0r
Copy link
Member

@itzpr3d4t0r itzpr3d4t0r commented Jan 13, 2023

This pull request resolves issue #171, and is a direct continuation of #157. The changes made include:

  • The Polygon.__new__ function now always allocates memory for three vertices, meaning it creates a triangle. It's important to note that all vertices will have uninitialized data. It's a waste of performance to set all vertices to 0.
  • The init function now resizes the memory that __new__ allocated if more than three vertices need to be allocated.
  • Slight simplifications in pgPolygon_FromObject, moved around some *was_sequence = 1s.
  • Fixed another issue that caused pgPolygon_FromObject to segfault when lists or tuples were passed as polygons

And The following program no longer segfaults:

from geometry import Polygon

poly = Polygon.__new__(Polygon)

poly[0] = (1, 2)

@itzpr3d4t0r itzpr3d4t0r changed the title Fixed Polygon.__new__ segfaulting and cleanup Fixed segfaults in poly __new__ and pgPolygon_FromObject Jan 13, 2023
@itzpr3d4t0r itzpr3d4t0r merged commit c946fd3 into main Jan 13, 2023
@itzpr3d4t0r itzpr3d4t0r deleted the fix_new_problem branch January 13, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant