From d24a2694124e62e3c8408e17f1859cbbcde7c727 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Tue, 20 Sep 2016 12:49:46 +0200 Subject: [PATCH] fixed segfault in code generated for getreply Change-Id: I343e50ac3efeab903dea48f2487bc36e176a4e0e Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/ttcn3/Statement.cc | 9 +++++---- compiler2/ttcn3/Statement.hh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc index 5ce6b1ce0..11614d38a 100644 --- a/compiler2/ttcn3/Statement.cc +++ b/compiler2/ttcn3/Statement.cc @@ -9284,7 +9284,7 @@ error: char* constr_params_str = NULL; char* constr_init_list_str = NULL; char* set_values_str = NULL; - if (has_decoded_modifier()) { + if (matched_ti != NULL && has_decoded_modifier()) { // store a pointer to the matched template, the decoding results from // decmatch templates might be reused to optimize decoded value redirects expr->expr = mputprintf(expr->expr, "&(%s), ", matched_ti->get_last_gen_expr()); @@ -9335,8 +9335,9 @@ error: const char* subrefs_str = (subrefs_expr.expr != NULL) ? subrefs_expr.expr : ""; if (v[i]->is_decoded()) { // set the silent parameter to 'true', so no errors are displayed - Template* matched_temp = matched_ti->get_Template()->get_refd_sub_template( - v[i]->get_subrefs(), false, NULL, true); + Template* matched_temp = matched_ti != NULL ? + matched_ti->get_Template()->get_refd_sub_template(v[i]->get_subrefs(), + false, NULL, true) : NULL; if (matched_temp != NULL) { matched_temp = matched_temp->get_template_refd_last(); } @@ -9460,7 +9461,7 @@ error: break; } } - if (unfoldable) { + if (unfoldable && matched_ti != NULL) { // the decmatch-check must be done at runtime use_decmatch_result = true; if (redir_coding_expr.preamble != NULL) { diff --git a/compiler2/ttcn3/Statement.hh b/compiler2/ttcn3/Statement.hh index e5135f9f9..ee5714c85 100644 --- a/compiler2/ttcn3/Statement.hh +++ b/compiler2/ttcn3/Statement.hh @@ -1131,7 +1131,7 @@ namespace Ttcn { * structure. A new class is generated for every value redirect, which * handles the redirecting. * @param matched_ti the template instance used for matching the redirected - * value + * value (if NULL, then the template instance is an 'any value' template) * @param base_class_prefix the namespace and/or class prefix of the * base value redirect class of the appropriate type */ void generate_code(expression_struct* expr, TemplateInstance* matched_ti, -- GitLab