Skip to content
  • Damien George's avatar
    py/objstr: Protect against creating bytes(n) with n negative. · 4e469085
    Damien George authored
    Prior to this patch uPy (on a 32-bit arch) would have severe issues when
    calling bytes(-1): such a call would call vstr_init_len(vstr, -1) which
    would then +1 on the len and call vstr_init(vstr, 0), which would then
    round this up and allocate a small amount of memory for the vstr.  The
    bytes constructor would then attempt to zero out all this memory, thinking
    it had allocated 2^32-1 bytes.
    4e469085