Browse Source

HPCC-17615 Fix SEH when empty xml tag supplied for STORED row

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 years ago
parent
commit
0b1f99e824

+ 4 - 1
ecl/hqlcpp/hqlcppds.cpp

@@ -508,7 +508,10 @@ IReferenceSelector * HqlCppTranslator::buildNewRow(BuildCtx & ctx, IHqlExpressio
             OwnedHqlExpr serializedRecord = getSerializedForm(record, serializeForm);
 
             OwnedHqlExpr temp = createDatasetF(no_getresult, LINK(serializedRecord), LINK(seqAttr), LINK(nameAttr), NULL);
-            OwnedHqlExpr row = createRow(no_selectnth, LINK(temp), createComma(getSizetConstant(1), createAttribute(noBoundCheckAtom)));
+
+            //Do not use noBoundCheck for STORED because invalid xml may be provided that defines no rows.
+            OwnedHqlExpr option = matchesConstantValue(seqAttr->queryChild(0), ResultSequenceStored) ? nullptr : createAttribute(noBoundCheckAtom);
+            OwnedHqlExpr row = createRow(no_selectnth, LINK(temp), createComma(getSizetConstant(1), option.getClear()));
             row.setown(ensureDeserialized(row, expr->queryType(), serializeForm));
             return buildNewRow(ctx, row);
         }

+ 3 - 0
testing/regress/ecl/key/rowstored.xml

@@ -0,0 +1,3 @@
+<Dataset name='Result 1'>
+ <Row><id>0</id><child><id>0</id></child></Row>
+</Dataset>

+ 28 - 0
testing/regress/ecl/rowstored.ecl

@@ -0,0 +1,28 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+r1 := record
+unsigned id;
+    end;
+
+r2 := record
+unsigned id;
+r1     child;
+end;
+
+r2 value := dataset([], r2)[1] : stored('inDs');
+output(value);

+ 3 - 0
testing/regress/ecl/rowstored.queryxml

@@ -0,0 +1,3 @@
+<query>
+ <inDs></inDs>
+</query>