diff --git a/src/engine/engine_plugin.cc b/src/engine/engine_plugin.cc index ec0a1ef50a..850d4269db 100644 --- a/src/engine/engine_plugin.cc +++ b/src/engine/engine_plugin.cc @@ -194,7 +194,7 @@ bool GlobalTable::CopyObject(mjpPlugin& dst, const mjpPlugin& src, Er // check and copy plugin attributes std::unique_ptr[]> attributes_list; - if (src.nattribute) { + if (src.nattribute && src.nattribute <= kMaxAttributes) { attributes_list.reset(new(std::nothrow) std::unique_ptr[src.nattribute]); if (!attributes_list) { std::snprintf(err, sizeof(err), "failed to allocate memory for plugin attribute list"); diff --git a/src/engine/engine_print.c b/src/engine/engine_print.c index a8f407d934..57d11962e7 100644 --- a/src/engine/engine_print.c +++ b/src/engine/engine_print.c @@ -480,7 +480,7 @@ static bool validateFloatFormat(const char* float_format) { // flag characters. allow at most one of each flag const char flag_characters[] = "-+ #0"; int flag_character_counts[sizeof(flag_characters)] = { 0 }; - char* c; + const char* c; while (c = strchr(flag_characters, float_format[cur_idx]), c != NULL) { int flag_idx = (c - flag_characters)/sizeof(char); flag_character_counts[flag_idx]++;