Commit 7133d917 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py: mp_buffer_info_t::buf may be valid, but NULL for empty objects.

This happens for example for zero-size arrays. As .get_buffer() method now
has explicit return value, it's enough to distinguish success vs failure
of getting buffer.
parent 5f47ebbf
......@@ -410,7 +410,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
return false;
}
int ret = type->buffer_p.get_buffer(obj, bufinfo, flags);
if (ret != 0 || bufinfo->buf == NULL) {
if (ret != 0) {
return false;
}
return true;
......
......@@ -210,7 +210,7 @@ typedef struct _mp_buffer_info_t {
// them with ver = sizeof(struct). Cons: overkill for *micro*?
//int ver; // ?
void *buf;
void *buf; // can be NULL if len == 0
mp_int_t len; // in bytes
int typecode; // as per binary.h
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment