Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64fc13a

Browse filesBrowse files
tacaswellQuLogic
authored andcommitted
MNT: ensure pre-multiplication casting to prevent overflow
1 parent 41833f5 commit 64fc13a
Copy full SHA for 64fc13a

File tree

Expand file treeCollapse file tree

4 files changed

+8
-6
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+8
-6
lines changed

‎src/_backend_agg.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void BufferRegion::to_string_argb(uint8_t *buf)
1111
unsigned char tmp;
1212
size_t i, j;
1313

14-
memcpy(buf, data, height * stride);
14+
memcpy(buf, data, (size_t) height * stride);
1515

1616
for (i = 0; i < (size_t)height; ++i) {
1717
pix = buf + i * stride;

‎src/_backend_agg.h

Copy file name to clipboardExpand all lines: src/_backend_agg.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ class QuadMeshGenerator
11241124

11251125
inline size_t num_paths() const
11261126
{
1127-
return m_meshWidth * m_meshHeight;
1127+
return (size_t) m_meshWidth * m_meshHeight;
11281128
}
11291129

11301130
inline path_iterator operator()(size_t i) const

‎src/_backend_agg_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg_wrapper.cpp
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static PyObject *PyBufferRegion_to_string(PyBufferRegion *self, PyObject *args)
5353
return NULL;
5454
}
5555
return PyBytes_FromStringAndSize((const char *)self->x->get_data(),
56-
self->x->get_height() * self->x->get_stride());
56+
(Py_ssize_t) self->x->get_height() * self->x->get_stride());
5757
}
5858

5959
/* TODO: This doesn't seem to be used internally. Remove? */
@@ -98,8 +98,10 @@ static PyObject *PyBufferRegion_to_string_argb(PyBufferRegion *self, PyObject *a
9898
}
9999
PyObject *bufobj;
100100
uint8_t *buf;
101-
102-
bufobj = PyBytes_FromStringAndSize(NULL, self->x->get_height() * self->x->get_stride());
101+
Py_ssize_t height, stride;
102+
height = self->x->get_height();
103+
stride = self->x->get_stride();
104+
bufobj = PyBytes_FromStringAndSize(NULL, height * stride);
103105
buf = (uint8_t *)PyBytes_AS_STRING(bufobj);
104106

105107
CALL_CPP_CLEANUP("to_string_argb", (self->x->to_string_argb(buf)), Py_DECREF(bufobj));

‎src/_path.h

Copy file name to clipboardExpand all lines: src/_path.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ bool convert_to_string(PathIterator &path,
12221222
clipped_t clipped(nan_removed, do_clip, clip_rect);
12231223
simplify_t simplified(clipped, simplify, path.simplify_threshold());
12241224

1225-
buffersize = path.total_vertices() * (precision + 5) * 4;
1225+
buffersize = (size_t) path.total_vertices() * (precision + 5) * 4;
12261226
if (buffersize == 0) {
12271227
return true;
12281228
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.