Skip to content

Commit 558fd5d

Browse files
committed
py/stream: ioctl(): Properly support 2-arg form.
1 parent 6c3db26 commit 558fd5d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

py/stream.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,14 @@ STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
414414
const mp_stream_p_t *stream_p = mp_get_stream_raise(args[0], MP_STREAM_OP_IOCTL);
415415

416416
mp_buffer_info_t bufinfo;
417-
uintptr_t val;
418-
if (MP_OBJ_IS_INT(args[2])) {
419-
val = mp_obj_get_int(args[2]);
420-
} else {
421-
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);
422-
val = (uintptr_t)bufinfo.buf;
417+
uintptr_t val = 0;
418+
if (n_args > 2) {
419+
if (MP_OBJ_IS_INT(args[2])) {
420+
val = mp_obj_get_int(args[2]);
421+
} else {
422+
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
423+
val = (uintptr_t)bufinfo.buf;
424+
}
423425
}
424426

425427
int error;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy