Skip to content

Commit 7885a42

Browse files
committed
py/stream: Remove unnecessary checks for NULL return from vstr_add_len.
The vstr argument to the calls to vstr_add_len are dynamically allocated (ie fixed_buf=false) and so vstr_add_len will never return NULL. So there's no need to check for it. Any out-of-memory errors are raised by the call to m_renew in vstr_ensure_extra.
1 parent 96fd80d commit 7885a42

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

py/stream.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte fl
141141
mp_uint_t last_buf_offset = 0;
142142
while (more_bytes > 0) {
143143
char *p = vstr_add_len(&vstr, more_bytes);
144-
if (p == NULL) {
145-
mp_raise_msg(&mp_type_MemoryError, "out of memory");
146-
}
147144
int error;
148145
mp_uint_t out_sz = mp_stream_read_exactly(args[0], p, more_bytes, &error);
149146
if (error != 0) {
@@ -380,10 +377,6 @@ STATIC mp_obj_t stream_unbuffered_readline(size_t n_args, const mp_obj_t *args)
380377

381378
while (max_size == -1 || max_size-- != 0) {
382379
char *p = vstr_add_len(&vstr, 1);
383-
if (p == NULL) {
384-
mp_raise_msg(&mp_type_MemoryError, "out of memory");
385-
}
386-
387380
int error;
388381
mp_uint_t out_sz = stream_p->read(args[0], p, 1, &error);
389382
if (out_sz == MP_STREAM_ERROR) {

0 commit comments

Comments
 (0)