[libcamera-devel] [PATCH] libcamera: yaml_parser: Increase sentinel to 100k

Xavier Roumegue xavier.roumegue at oss.nxp.com
Tue Nov 15 14:12:26 CET 2022


The original sentinel limit is reached with file holding dewarping
mapping coordinates. A long term solution would be to use a binary file
format to store high density data file. But for now, simply increase the
limit to a high arbitrary value.

Signed-off-by: Xavier Roumegue <xavier.roumegue at oss.nxp.com>
---
 src/libcamera/yaml_parser.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index d8a7c2f9..8bd5eda3 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -668,6 +668,7 @@ void YamlParserContext::readValue(std::string &value, EventPtr event)
 int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,
 					     const std::function<int(EventPtr event)> &parseItem)
 {
+	constexpr unsigned int sentinelLimit = 100000;
 	yaml_event_type_t endEventType = YAML_SEQUENCE_END_EVENT;
 	if (type == YamlObject::Type::Dictionary)
 		endEventType = YAML_MAPPING_END_EVENT;
@@ -676,7 +677,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,
 	 * Add a safety counter to make sure we don't loop indefinitely in case
 	 * the YAML file is malformed.
 	 */
-	for (unsigned int sentinel = 1000; sentinel; sentinel--) {
+	for (unsigned int sentinel = sentinelLimit; sentinel; sentinel--) {
 		auto evt = nextEvent();
 		if (!evt)
 			return -EINVAL;
@@ -690,7 +691,8 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,
 	}
 
 	LOG(YamlParser, Error) << "The YAML file contains a List or Dictionary"
-				  " whose size exceeds the parser's limit (1000)";
+				  " whose size exceeds the parser's limit ("
+			       << sentinelLimit << ")";
 
 	return -EINVAL;
 }
-- 
2.38.1



More information about the libcamera-devel mailing list