File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 33
33
#include "lib/oofatfs/diskio.h"
34
34
#include "py/mpstate.h"
35
35
#include "py/obj.h"
36
+ #include "py/objstr.h"
36
37
#include "py/runtime.h"
37
38
#include "shared-bindings/os/__init__.h"
38
39
@@ -195,11 +196,11 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync);
195
196
//|
196
197
STATIC mp_obj_t os_urandom (mp_obj_t size_in ) {
197
198
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 )) {
200
201
mp_raise_NotImplementedError (translate ("No hardware random available" ));
201
202
}
202
- return mp_obj_new_bytes ( tmp , size ) ;
203
+ return result ;
203
204
}
204
205
MP_DEFINE_CONST_FUN_OBJ_1 (os_urandom_obj , os_urandom );
205
206
You can’t perform that action at this time.
0 commit comments