Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit64fc13a

Browse files
tacaswellQuLogic
authored andcommitted
MNT: ensure pre-multiplication casting to prevent overflow
1 parent41833f5 commit64fc13a

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

‎src/_backend_agg.cpp‎

Lines 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
unsignedchar 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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ class QuadMeshGenerator
11241124

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

11301130
inline path_iteratoroperator()(size_t i)const

‎src/_backend_agg_wrapper.cpp‎

Lines 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
returnNULL;
5454
}
5555
returnPyBytes_FromStringAndSize((constchar *)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‎

Lines 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_tclipped(nan_removed, do_clip, clip_rect);
12231223
simplify_tsimplified(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
returntrue;
12281228
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp