diff options
author | Simon Gibbons <simongibbons@gmail.com> | 2018-11-08 20:16:34 +0000 |
---|---|---|
committer | Simon Gibbons <simongibbons@gmail.com> | 2018-11-10 11:31:52 +0000 |
commit | fbdcb5b7b38a7063357f881397ccdc546f46ec5b (patch) | |
tree | fa26c05e7de5c7ee7ff6ca44cc1caa7c98bd603f /numpy/core/setup.py | |
parent | d0e2f1ac0c0fb4aaf791c9082cff1d6b04545410 (diff) | |
download | numpy-fbdcb5b7b38a7063357f881397ccdc546f46ec5b.tar.gz |
BUG: Fix segfault when an error occurs in np.fromfile
There is a problem with the way in which we handle
errors which occur in the call to `PyArray_FromFile`
in `np.fromfile`.
The problem here is twofold.
1. The return value isn't checked, therefore if we reach
the fail block, we will attempt a DECREF on a NULL and
go down in flames.
2. The cleanup code on the filepointers (most notabily the
call to `npy_PyFile_DupClose2`) assumes that there is no
error set to work.
This PR addresses these issues
1. By adding a NULL check to the fail block to ensure we don't
attempt a DECREF on a NULL.
2. By saving the error state before attempting the cleanup code
on the file descriptor, and then restoring it after.
Fixes: #12300
Diffstat (limited to 'numpy/core/setup.py')
0 files changed, 0 insertions, 0 deletions