From b63701261ecfaf84d58b544fb1d4ccee8c39bc74 Mon Sep 17 00:00:00 2001
From: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
Date: Thu, 13 Oct 2016 12:41:32 +0200
Subject: [PATCH] Segmentation fault fix, when explicitly unspecifield field is
 present

Change-Id: Id5f118f22f33723ed1290ef939bd6a7c0292a228
Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
---
 compiler2/subtype.cc                          |  3 ++
 function_test/XER_EncDec/XER_EncDec_TD.script | 49 +++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/compiler2/subtype.cc b/compiler2/subtype.cc
index 0099ec9ae..9d8e168f7 100644
--- a/compiler2/subtype.cc
+++ b/compiler2/subtype.cc
@@ -17,6 +17,7 @@
  *   Raduly, Csaba
  *   Szabados, Kristof
  *   Szabo, Janos Zoltan – initial implementation
+ *   Szabo, Bence Janos
  *   Szalai, Gabor
  *   Tatarka, Gabor
  *   Zalanyi, Balazs Andor
@@ -1978,6 +1979,8 @@ void SubType::chk_this_template(Template *templ)
   case Template::USTR_PATTERN:
 	  chk_this_template_pattern("universal charstring", templ);
 	  break;
+  case Template::TEMPLATE_NOTUSED:
+    break;
   case Template::TEMPLATE_ERROR:
     break;
   default:
diff --git a/function_test/XER_EncDec/XER_EncDec_TD.script b/function_test/XER_EncDec/XER_EncDec_TD.script
index 2a2981ba2..7a0c238df 100644
--- a/function_test/XER_EncDec/XER_EncDec_TD.script
+++ b/function_test/XER_EncDec/XER_EncDec_TD.script
@@ -8,6 +8,7 @@
 .* Contributors:
 .*   Balasko, Jeno
 .*   Baranyi, Botond
+.*   Szabo, Bence Janos
 .*
 .******************************************************************************/
 :text.
@@ -67,6 +68,9 @@ A     2014-04-29   EBOTBAR    New document
 .*---------------------------------------------------------------------*
 :h3. Encoding record with any element from unqualified namespace
 .*---------------------------------------------------------------------*
+.*---------------------------------------------------------------------*
+:h4. Encoding record template with explicitly unspecified field
+.*---------------------------------------------------------------------*
 :xmp tab=0.
 
 <TC - Encoding record with any element from unqualified namespace>
@@ -1229,6 +1233,51 @@ Dynamic test case error: While XER-decoding type '@Temp.any_elem_rec_of': Index
   
 :exmp.
 
+.*---------------------------------------------------------------------*
+:h4. Encoding record template with explicitly unspecified field
+.*---------------------------------------------------------------------*
+:xmp tab=0.
+
+<TC - Encoding record template with explicitly unspecified field>
+
+<STATIC>
+
+type component Test_CT{};
+
+<TTCN_TC:PURE_EXEC>
+
+type record MyType
+{
+  universal charstring foo
+}
+with {
+  encode "XML";
+  variant "element";
+};
+
+external function ef_xer_enc(in MyType par) return octetstring
+  with { extension "prototype(convert) encode (XER:XER_EXTENDED) errorbehavior(ALL:ERROR)" }
+
+testcase tc_enc_explicitly_unspecified() runs on Test_CT {
+  template MyType myTemp := { foo := - };
+
+  var octetstring v_res := ef_xer_enc(valueof(myTemp));
+
+  setverdict(pass);
+}
+
+control {
+  execute(tc_enc_explicitly_unspecified());
+}
+
+<RESULT>
+
+Dynamic test case error: Performing valueof or send operation on a non-specific template of type @Temp.MyType
+
+<END_TC>  
+  
+:exmp.
+
 .*---------------------------------------------------------------------*
 :h1.REFERENCES
 .*---------------------------------------------------------------------*
-- 
GitLab