From 0e595d05c9fd519c724e6e73c7f8614dcdbf3a4c Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Thu, 14 Jun 2018 14:13:15 +0200 Subject: [PATCH] RAW enc: fixed calculation of needed bits for integers with signed bit (bug 532595) Change-Id: Ie2b7a36e6ceb0127da2d258674464ca45399efb3 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- core/Integer.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Integer.cc b/core/Integer.cc index 57404d663..4d4ec4935 100644 --- a/core/Integer.cc +++ b/core/Integer.cc @@ -1176,7 +1176,11 @@ int INTEGER::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) } else { // not IntX, use the field length length = (p_td.raw->fieldlength + 7) / 8; - if (min_bits(value) > p_td.raw->fieldlength) { + int min_bits_ = min_bits(value); + if (p_td.raw->comp == SG_SG_BIT) { + ++min_bits_; + } + if (min_bits_ > p_td.raw->fieldlength) { TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_LEN_ERR, "There are insufficient bits to encode '%s' : ", p_td.name); value = 0; // substitute with zero -- GitLab