File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333#include "lib/oofatfs/diskio.h"
3434#include "py/mpstate.h"
3535#include "py/obj.h"
36+ #include "py/objstr.h"
3637#include "py/runtime.h"
3738#include "shared-bindings/os/__init__.h"
3839
@@ -195,11 +196,11 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync);
195196//|
196197STATIC mp_obj_t os_urandom (mp_obj_t size_in ) {
197198 mp_int_t size = mp_obj_get_int (size_in );
198- uint8_t tmp [ size ] ;
199- if (!common_hal_os_urandom (tmp , size )) {
199+ mp_obj_str_t * result = MP_OBJ_TO_PTR ( mp_obj_new_bytes_of_zeros ( size )) ;
200+ if (!common_hal_os_urandom (( uint8_t * ) result -> data , size )) {
200201 mp_raise_NotImplementedError (translate ("No hardware random available" ));
201202 }
202- return mp_obj_new_bytes ( tmp , size ) ;
203+ return result ;
203204}
204205MP_DEFINE_CONST_FUN_OBJ_1 (os_urandom_obj , os_urandom );
205206
You can’t perform that action at this time.
0 commit comments