浏览代码

Merge pull request #2590 from ghalliday/badimport

Fix potential use of NULL pointer in printf %s

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 年之前
父节点
当前提交
ae1889e6cf
共有 2 个文件被更改,包括 23 次插入1 次删除
  1. 4 1
      ecl/hql/hqlgram2.cpp
  2. 19 0
      ecl/regress/badimport.ecl

+ 4 - 1
ecl/hql/hqlgram2.cpp

@@ -9620,7 +9620,10 @@ IHqlExpression * HqlGram::resolveImportModule(const attribute & errpos, IHqlExpr
     OwnedHqlExpr resolved = parent->queryScope()->lookupSymbol(childName, LSFpublic, lookupCtx);
     if (!resolved)
     {
-        reportError(ERR_OBJ_NOSUCHFIELD, errpos, "Object '%s' does not have a field named '%s'", parent->queryName()->str(), childName->str());
+        const char * parentName = parent->queryName()->str();
+        if (!parentName)
+            parentName = "$";
+        reportError(ERR_OBJ_NOSUCHFIELD, errpos, "Object '%s' does not have a field named '%s'", parentName, childName->str());
         return NULL;
     }
     IHqlScope * ret = resolved->queryScope();

+ 19 - 0
ecl/regress/badimport.ecl

@@ -0,0 +1,19 @@
+/*##############################################################################
+
+    Copyright (C) 2011 HPCC Systems.
+
+    All rights reserved. This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as
+    published by the Free Software Foundation, either version 3 of the
+    License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+############################################################################## */
+
+import $.x;