Skip to content

Commit

Permalink
Initialize coordinates to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 1, 2022
1 parent 89d0d38 commit 1e09241
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tests/test_imagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_path_odd_number_of_coordinates():
[
([0, 1, 2, 3], (0.0, 1.0, 2.0, 3.0)),
([3, 2, 1, 0], (1.0, 0.0, 3.0, 2.0)),
(1, (0.0, 0.0, 0.0, 0.0)),
],
)
def test_getbbox(coords, expected):
Expand Down
2 changes: 1 addition & 1 deletion src/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ alloc_array(Py_ssize_t count) {
if ((unsigned long long)count > (SIZE_MAX / (2 * sizeof(double))) - 1) {
return ImagingError_MemoryError();
}
xy = malloc(2 * count * sizeof(double) + 1);
xy = calloc(2 * count * sizeof(double) + 1, sizeof(double));
if (!xy) {
ImagingError_MemoryError();
}
Expand Down

3 comments on commit 1e09241

@risicle
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now allocating 8x the amount of memory it previously was - is that intentional?

@wiredfool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sizeof(double) should only be in one of the arguments.

@radarhere
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #5958 to address this.

Please sign in to comment.