Skip to content
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

Fix memory access out of bounds in numpy + chrome 89 #1474

Merged
merged 23 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Okay I think this works now?
  • Loading branch information
Hood committed Apr 16, 2021
commit 215112ff04e044f3443fefae7201d8d815aabe05
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ all: check \
build/pyodide.asm.js: \
src/core/docstring.o \
src/core/error_handling.o \
src/core/PyArray_Broadcast.o \
src/core/numpy_patch.o \
src/core/hiwire.o \
src/core/js2python.o \
src/core/jsproxy.o \
Expand Down
6 changes: 3 additions & 3 deletions src/core/PyArray_Broadcast.c → src/core/numpy_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "error_handling.h"

static void
void
set_shape_mismatch_err()
{
PyErr_SetString(PyExc_ValueError,
Expand Down Expand Up @@ -37,7 +37,7 @@ EM_JS_NUM(int, PyArray_Broadcast_part1, (void* mit), {
// for (i = 0; i < nd; i++) {
// mit->dimensions[i] = 1;
// }
HEAP32.subarray((mit + 24) / 4, (mit + 24 + nd) / 4).fill(1);
HEAP32.subarray((mit + 24) / 4, (mit + 24 + 4 * nd) / 4).fill(1);

for (j = 0; j < numiter; j++) {
// it = mit->iters[i];
Expand All @@ -46,7 +46,7 @@ EM_JS_NUM(int, PyArray_Broadcast_part1, (void* mit), {
/* This prepends 1 to shapes not already equal to nd */
// k = i + PyArray_NDIM(it->ao) - nd;
let it_ao = HEAP32[(it + 660) / 4];
let it_ao_ndim = HEAP32[(ao + 12) / 4];
let it_ao_ndim = HEAP32[(it_ao + 12) / 4];
let k = i + it_ao_ndim - nd;
if (k >= 0) {
// tmp = PyArray_DIMS(it->ao)[k];
Expand Down