@@ -119,10 +119,16 @@ std::optional<ryml::Tree> ParseYAMLFromString(ryml::csubstr yaml, ryml::csubstr
119119#else
120120 callbacks.m_user_data = static_cast <void *>(&context);
121121 callbacks.m_error = [](const char * msg, size_t msg_len, ryml::Location location, void * user_data) {
122- RapidYAMLContext* context = static_cast <RapidYAMLContext*>(user_data);
123-
124- Error::SetString (context->error , std::string (msg, msg_len));
125- std::longjmp (context->env , 1 );
122+ if (RapidYAMLContext* context = static_cast <RapidYAMLContext*>(user_data))
123+ {
124+ Error::SetString (context->error , std::string (msg, msg_len));
125+ std::longjmp (context->env , 1 );
126+ }
127+ else
128+ {
129+ std::string description (msg, msg_len);
130+ pxFailRel (description.c_str ());
131+ }
126132 };
127133#endif
128134
@@ -145,7 +151,11 @@ std::optional<ryml::Tree> ParseYAMLFromString(ryml::csubstr yaml, ryml::csubstr
145151
146152 // Callbacks passed to ryml::Tree are used for value parsing errors later,
147153 // so we need to clear the context before it goes out of scope.
154+ #if RYML_VERSION_MAJOR > 0 || RYML_VERSION_MINOR >= 11
148155 callbacks.set_user_data (nullptr );
156+ #else
157+ callbacks.m_user_data = nullptr ;
158+ #endif
149159 tree.callbacks (callbacks);
150160
151161 return tree;
0 commit comments