From b36cb6686f7d788d319586b360aff47eb7832d0c Mon Sep 17 00:00:00 2001 From: kristof <Kristof.Szabados@ericsson.com> Date: Sat, 25 Feb 2017 09:33:46 +0100 Subject: [PATCH] add protection against null pointer exception in the form of an error message that the user can use to find the reason for the problem. Signed-off-by: kristof <Kristof.Szabados@ericsson.com> --- core/ASN_CharacterString.cc | 4 ++++ core/ASN_EmbeddedPDV.cc | 4 ++++ core/ASN_External.cc | 4 ++++ core/ASN_Null.cc | 1 + core/Bitstring.cc | 3 ++- core/Boolean.cc | 1 + core/Charstring.cc | 3 ++- core/Component.cc | 1 + core/Float.cc | 1 + core/Hexstring.cc | 3 ++- core/Integer.cc | 1 + core/Objid.cc | 1 + core/Octetstring.cc | 3 ++- core/Template.cc | 4 ++++ core/Universal_charstring.cc | 3 ++- core/Verdicttype.cc | 1 + 16 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/ASN_CharacterString.cc b/core/ASN_CharacterString.cc index c1c8a23bb..b81fad277 100644 --- a/core/ASN_CharacterString.cc +++ b/core/ASN_CharacterString.cc @@ -597,6 +597,7 @@ Module_Param* CHARACTER_STRING_identification_template::get_param(Module_Param_N } break; } default: + TTCN_error("Referencing an uninitialized/unsupported value of type CHARACTER STRING.identification."); break; } if (is_ifpresent) { @@ -1933,6 +1934,7 @@ Module_Param* CHARACTER_STRING_identification_syntaxes_template::get_param(Modul } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type CHARACTER STRING.identification.syntaxes."); break; } if (is_ifpresent) { @@ -2666,6 +2668,7 @@ Module_Param* CHARACTER_STRING_identification_context__negotiation_template::get } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type CHARACTER STRING.identification.context-negotiation."); break; } if (is_ifpresent) { @@ -3546,6 +3549,7 @@ Module_Param* CHARACTER_STRING_template::get_param(Module_Param_Name& param_name } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type CHARACTER STRING."); break; } if (is_ifpresent) { diff --git a/core/ASN_EmbeddedPDV.cc b/core/ASN_EmbeddedPDV.cc index a5a89e450..9965e78eb 100644 --- a/core/ASN_EmbeddedPDV.cc +++ b/core/ASN_EmbeddedPDV.cc @@ -584,6 +584,7 @@ Module_Param* EMBEDDED_PDV_identification_template::get_param(Module_Param_Name& } break; } default: + TTCN_error("Referencing an uninitialized/unsupported value of type EMBEDDED PDV.identification."); break; } if (is_ifpresent) { @@ -1937,6 +1938,7 @@ Module_Param* EMBEDDED_PDV_identification_syntaxes_template::get_param(Module_Pa } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type EMBEDDED PDV.identification.syntaxes."); break; } if (is_ifpresent) { @@ -2678,6 +2680,7 @@ Module_Param* EMBEDDED_PDV_identification_context__negotiation_template::get_par } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type EMBEDDED PDV.identification.context-negotiation."); break; } if (is_ifpresent) { @@ -3563,6 +3566,7 @@ Module_Param* EMBEDDED_PDV_template::get_param(Module_Param_Name& param_name) co } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type EMBEDDED PDV."); break; } if (is_ifpresent) { diff --git a/core/ASN_External.cc b/core/ASN_External.cc index ab94f3288..580a163b8 100644 --- a/core/ASN_External.cc +++ b/core/ASN_External.cc @@ -1214,6 +1214,7 @@ Module_Param* EXTERNAL_identification_template::get_param(Module_Param_Name& par } break; } default: + TTCN_error("Referencing an uninitialized/unsupported value of type EXTERNAL.identification."); break; } if (is_ifpresent) { @@ -2239,6 +2240,7 @@ Module_Param* EXTERNAL_identification_syntaxes_template::get_param(Module_Param_ } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type EXTERNAL.identification.syntaxtes ."); break; } if (is_ifpresent) { @@ -2885,6 +2887,7 @@ Module_Param* EXTERNAL_identification_context__negotiation_template::get_param(M } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type EXTERNAL.identification.context-negotiation."); break; } if (is_ifpresent) { @@ -3652,6 +3655,7 @@ Module_Param* EXTERNAL_template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type EXTERNAL."); break; } if (is_ifpresent) { diff --git a/core/ASN_Null.cc b/core/ASN_Null.cc index f00bff8a2..a1122fa2a 100644 --- a/core/ASN_Null.cc +++ b/core/ASN_Null.cc @@ -624,6 +624,7 @@ Module_Param* ASN_NULL_template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported ASN.1 NULL template."); break; } if (is_ifpresent) { diff --git a/core/Bitstring.cc b/core/Bitstring.cc index d2d2637d3..953a108d5 100644 --- a/core/Bitstring.cc +++ b/core/Bitstring.cc @@ -2023,9 +2023,10 @@ Module_Param* BITSTRING_template::get_param(Module_Param_Name& param_name) const mp = new Module_Param_Bitstring_Template(pattern_value->n_elements, val_cpy); break; } case DECODE_MATCH: - mp->error("Referencing a decoded content matching template is not supported."); + TTCN_error("Referencing a decoded content matching template is not supported."); break; default: + TTCN_error("Referencing an uninitialized/unsupported bitstring template."); break; } if (is_ifpresent) { diff --git a/core/Boolean.cc b/core/Boolean.cc index e0d3fe215..13dca0093 100644 --- a/core/Boolean.cc +++ b/core/Boolean.cc @@ -1114,6 +1114,7 @@ Module_Param* BOOLEAN_template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported boolean template."); break; } if (is_ifpresent) { diff --git a/core/Charstring.cc b/core/Charstring.cc index 52e74544c..eeb4bce4f 100644 --- a/core/Charstring.cc +++ b/core/Charstring.cc @@ -2838,9 +2838,10 @@ Module_Param* CHARSTRING_template::get_param(Module_Param_Name& param_name) cons mp = new Module_Param_Pattern(mcopystr(single_value), pattern_value.nocase); break; case DECODE_MATCH: - mp->error("Referencing a decoded content matching template is not supported."); + TTCN_error("Referencing a decoded content matching template is not supported."); break; default: + TTCN_error("Referencing an uninitialized/unsupported charstring template."); break; } if (is_ifpresent) { diff --git a/core/Component.cc b/core/Component.cc index adc890f6b..c634058de 100644 --- a/core/Component.cc +++ b/core/Component.cc @@ -746,6 +746,7 @@ Module_Param* COMPONENT_template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported component reference template."); break; } if (is_ifpresent) { diff --git a/core/Float.cc b/core/Float.cc index fe599dc95..9aaa02768 100644 --- a/core/Float.cc +++ b/core/Float.cc @@ -1647,6 +1647,7 @@ Module_Param* FLOAT_template::get_param(Module_Param_Name& param_name) const value_range.max_value, value_range.max_is_present, value_range.min_is_exclusive, value_range.max_is_exclusive); break; default: + TTCN_error("Referencing an uninitialized/unsupported float template."); break; } if (is_ifpresent) { diff --git a/core/Hexstring.cc b/core/Hexstring.cc index ef55ca90b..f4e520869 100644 --- a/core/Hexstring.cc +++ b/core/Hexstring.cc @@ -1917,9 +1917,10 @@ Module_Param* HEXSTRING_template::get_param(Module_Param_Name& param_name) const mp = new Module_Param_Hexstring_Template(pattern_value->n_elements, val_cpy); break; } case DECODE_MATCH: - mp->error("Referencing a decoded content matching template is not supported."); + TTCN_error("Referencing a decoded content matching template is not supported."); break; default: + TTCN_error("Referencing an uninitialized/unsupported hexstring template."); break; } if (is_ifpresent) { diff --git a/core/Integer.cc b/core/Integer.cc index 62648d86e..9f937592b 100644 --- a/core/Integer.cc +++ b/core/Integer.cc @@ -2549,6 +2549,7 @@ Module_Param* INTEGER_template::get_param(Module_Param_Name& param_name) const mp = new Module_Param_IntRange(lower_bound, upper_bound, value_range.min_is_exclusive, value_range.max_is_exclusive); break; } default: + TTCN_error("Referencing an uninitialized/unsupported integer template."); break; } if (is_ifpresent) { diff --git a/core/Objid.cc b/core/Objid.cc index 97ef19a21..f1b58ad74 100644 --- a/core/Objid.cc +++ b/core/Objid.cc @@ -982,6 +982,7 @@ Module_Param* OBJID_template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported objid template."); break; } if (is_ifpresent) { diff --git a/core/Octetstring.cc b/core/Octetstring.cc index 03375184a..62945fb1c 100644 --- a/core/Octetstring.cc +++ b/core/Octetstring.cc @@ -2154,9 +2154,10 @@ Module_Param* OCTETSTRING_template::get_param(Module_Param_Name& param_name) con mp = new Module_Param_Octetstring_Template(pattern_value->n_elements, val_cpy); break; } case DECODE_MATCH: - mp->error("Referencing a decoded content matching template is not supported."); + TTCN_error("Referencing a decoded content matching template is not supported."); break; default: + TTCN_error("Referencing an uninitialized/unsupported octetstring template."); break; } if (is_ifpresent) { diff --git a/core/Template.cc b/core/Template.cc index 5f3c5039d..75e1fc7b0 100644 --- a/core/Template.cc +++ b/core/Template.cc @@ -1404,6 +1404,7 @@ Module_Param* Record_Of_Template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type %s.", get_descriptor()->name); break; } if (is_ifpresent) { @@ -2290,6 +2291,7 @@ Module_Param* Set_Of_Template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type %s.", get_descriptor()->name); break; } if (is_ifpresent) { @@ -2976,6 +2978,7 @@ Module_Param* Record_Template::get_param(Module_Param_Name& param_name) const } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type %s.", get_descriptor()->name); break; } if (is_ifpresent) { @@ -3365,6 +3368,7 @@ Module_Param* Empty_Record_Template::get_param(Module_Param_Name& param_name) co } break; } default: + TTCN_error("Referencing an uninitialized/unsupported template of type %s.", get_descriptor()->name); break; } if (is_ifpresent) { diff --git a/core/Universal_charstring.cc b/core/Universal_charstring.cc index a454844a0..1803a8b3d 100644 --- a/core/Universal_charstring.cc +++ b/core/Universal_charstring.cc @@ -4580,9 +4580,10 @@ Module_Param* UNIVERSAL_CHARSTRING_template::get_param(Module_Param_Name& param_ mp = new Module_Param_Pattern(mcopystr(*pattern_string), pattern_value.nocase); break; case DECODE_MATCH: - mp->error("Referencing a decoded content matching template is not supported."); + TTCN_error("Referencing a decoded content matching template is not supported."); break; default: + TTCN_error("Referencing an uninitialized/unsupported universal charstring template."); break; } if (is_ifpresent) { diff --git a/core/Verdicttype.cc b/core/Verdicttype.cc index 86cbd1016..133ebd945 100644 --- a/core/Verdicttype.cc +++ b/core/Verdicttype.cc @@ -759,6 +759,7 @@ Module_Param* VERDICTTYPE_template::get_param(Module_Param_Name& param_name) con } break; } default: + TTCN_error("Referencing an uninitialized/unsupported verdict template."); break; } if (is_ifpresent) { -- GitLab