From 0661a2740085db314305a894cd3aa10fcae0aca3 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 5 May 2021 13:02:41 +1000 Subject: [PATCH] SITL: ensure st.size is valid when loading model json Before this patch st.size is undefined when we use it to create a buffer on the stack - probably not a good thing. --- libraries/SITL/SIM_Frame.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/SITL/SIM_Frame.cpp b/libraries/SITL/SIM_Frame.cpp index f0fefe09ed..639b6deecd 100644 --- a/libraries/SITL/SIM_Frame.cpp +++ b/libraries/SITL/SIM_Frame.cpp @@ -333,6 +333,9 @@ void Frame::load_frame_params(const char *model_json) fname = strdup(model_json); } else { IGNORE_RETURN(asprintf(&fname, "@ROMFS/models/%s", model_json)); + if (AP::FS().stat(model_json, &st) != 0) { + AP_HAL::panic("%s failed to load\n", model_json); + } } if (fname == nullptr) { AP_HAL::panic("%s failed to load\n", model_json);