From a1b39d5959377cb8f8aaab2a837aedddc3a2589b Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Mon, 9 Oct 2023 11:00:14 -0700 Subject: [PATCH] Fix a segfault in `simulate` on mouse scroll without a loaded model. Fixes #1089 PiperOrigin-RevId: 571985561 Change-Id: I4acc7c2a6032d678023783646c3f00cfe30641f2 --- simulate/simulate.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulate/simulate.cc b/simulate/simulate.cc index cb8bd4d6..d25362e3 100644 --- a/simulate/simulate.cc +++ b/simulate/simulate.cc @@ -1633,7 +1633,7 @@ void UiEvent(mjuiState* state) { // 3D scroll if (state->type==mjEVENT_SCROLL && state->mouserect==3) { // emulate vertical mouse motion = 2% of window height - if (!sim->is_passive_) { + if (sim->m_ && !sim->is_passive_) { mjv_moveCamera(sim->m_, mjMOUSE_ZOOM, 0, -zoom_increment*state->sy, &sim->scn, &sim->cam); } else { mjv_moveCameraFromState(