[libcamera-devel] libcamera: yaml_parser: Increase sentinel to 100k
diff mbox series

Message ID 20221115131226.2063586-1-xavier.roumegue@oss.nxp.com
State New
Headers show
Series
  • [libcamera-devel] libcamera: yaml_parser: Increase sentinel to 100k
Related show

Commit Message

Xavier Roumegue Nov. 15, 2022, 1:12 p.m. UTC
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@oss.nxp.com>
---
 src/libcamera/yaml_parser.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch
diff mbox series

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;
 }