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

BUG: Fix segfault when an error occurs in np.fromfile #12354

Merged
merged 1 commit into from
Nov 10, 2018

Commits on Nov 10, 2018

  1. 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: numpy#12300
    simongibbons committed Nov 10, 2018
    Configuration menu
    Copy the full SHA
    fbdcb5b View commit details
    Browse the repository at this point in the history