From 2734e083d8cb45537058876c80935abae8e5c234 Mon Sep 17 00:00:00 2001 From: David Nichols Date: Tue, 15 Dec 2015 11:43:06 +0100 Subject: [PATCH] refs #276 added additional parameter checking to FixedLengthAbstractIterator::constructor() --- qlib/FixedLengthUtil.qm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qlib/FixedLengthUtil.qm b/qlib/FixedLengthUtil.qm index 25e8ff8735..6b4c5fb911 100644 --- a/qlib/FixedLengthUtil.qm +++ b/qlib/FixedLengthUtil.qm @@ -237,6 +237,8 @@ public class FixedLengthUtil::FixedLengthAbstractIterator { /** @param spec Fixed-length line specification; see @ref fixedlengthspec for more information @param opts Global options; see @ref fixedlengthglobals for more information + + @throw FIXED-LENGTH-UTIL-INVALID-SPEC invalid record specification; invalid type or missing field length */ constructor(hash spec, *hash opts) { m_specs = spec; @@ -245,6 +247,8 @@ public class FixedLengthUtil::FixedLengthAbstractIterator { # Determine line lengths of each spec, for use by the default identifyType() method. We do this by building a reverse length -> type table. m_line_lengths = hash(); foreach string k in (m_specs.keyIterator()) { + if (m_specs{k}.typeCode() != NT_HASH) + throw "FIXED-LENGTH-UTIL-INVALID-SPEC", sprintf("expecting a record description hash assigned to record key %y; got type %y instead (value: %y)", k, m_specs{k}.type(), m_specs{k}); int len = 0; foreach string c in (m_specs{k}.keyIterator()) { if (!m_specs{k}{c}.length)