kopia lustrzana https://github.com/micropython/micropython
extmod/vfs_posix_file: Ensure file object has safe default fd.
With this commit, if file open fails, the object will have fd = -1 (closed) and the finaliser will not attempt to close anything. Fixes issue #13672. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>pull/13684/head
rodzic
31e131bd71
commit
2962e24167
|
@ -92,6 +92,7 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
|
|||
}
|
||||
|
||||
mp_obj_vfs_posix_file_t *o = mp_obj_malloc_with_finaliser(mp_obj_vfs_posix_file_t, type);
|
||||
o->fd = -1; // In case open() fails below, initialise this as a "closed" file object.
|
||||
|
||||
mp_obj_t fid = file_in;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue