Commit 199b53eb authored by Arpad Lovassy's avatar Arpad Lovassy Committed by Gerrit Code Review
Browse files

Merge "Fixed memory leak in JSON decoding of binary strings and big integers (bug 560464)"

parents 8bc90f01 cec03658
......@@ -1244,6 +1244,7 @@ int BITSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_
}
}
if (!error) {
clean_up();
init_struct(bits);
int bit_index = 0;
for (size_t i = 0; i < value_len; ++i) {
......
......@@ -1122,6 +1122,7 @@ int HEXSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_
}
}
if (!error) {
clean_up();
init_struct(nibbles);
int nibble_index = 0;
for (size_t i = 0; i < value_len; ++i) {
......
......@@ -1773,6 +1773,7 @@ int INTEGER::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_to
}
else if (JSON_TOKEN_NUMBER == token || use_default) {
char* number = mcopystrn(value, value_len);
clean_up();
if (from_string(number) && (int)value_len == get_nof_digits() + ('-' == value[0] ? 1 : 0)) {
bound_flag = TRUE;
} else {
......
......@@ -1381,6 +1381,7 @@ int OCTETSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer&
}
}
if (!error) {
clean_up();
init_struct(nibbles / 2);
if (value_len != 0) {
int octet_index = 0;
......
......@@ -5,3 +5,4 @@
*.log
logs/*.log
compile
result.txt
......@@ -58,6 +58,39 @@ testcase tc_jsonBasic_encdec_integer() runs on CT {
}
testcase tc_jsonBasic_encdec_integer_big() runs on CT {
const I_json x := 2222222222222222222222222222222222;
var I_json y := 2222222222222222222222222222222222;
var bitstring bs;
var bitstring expected := oct2bit(char2oct("2222222222222222222222222222222222"));
log("expected:",expected);
bs := f_json_enc_i2bs(x);
f_compare_bitstring(bs, expected);
bs := f_json_enc_i2bs(y);
f_compare_bitstring(bs, expected);
//encvalue
bs := encvalue(y);
f_compare_bitstring(bs, expected);
//decode test:
var I_json z := f_json_dec_bs2i(expected);
if ( y ==z ) {
setverdict(pass);
} else {
setverdict(fail);
}
var integer r := decvalue(expected, z);
if (r==0 and y==z){
setverdict(pass);
} else {
setverdict(fail);
}
}
testcase tc_jsonBasic_encdec_float1() runs on CT {
const F_json x := 2.0;
var F_json y := 2.0;
......@@ -933,6 +966,7 @@ testcase tc_jsonBasic_encdec_anytype_i() runs on CT {
control {
execute( tc_jsonBasic_encdec_integer() );
execute( tc_jsonBasic_encdec_integer_big() );
execute( tc_jsonBasic_encdec_float1() );
execute( tc_jsonBasic_encdec_float2() );
execute( tc_jsonBasic_encdec_float3() );
......
TTCN-3 Test Executor (single mode), version CRL 113 200/6 R6B
Using configuration file: `JsonBasicTest.cfg'
Warning: Section [GROUPS] of configuration file is ignored in single mode.
Warning: Section [COMPONENTS] of configuration file is ignored in single mode.
Warning: Section [MAIN_CONTROLLER] of configuration file is ignored in single mode.
Execution of control part in module JsonBasicASN1EncDecTest1 started.
Test case tc_asn1_i2bs started.
Test case tc_asn1_i2bs finished. Verdict: pass
Test case tc_asn1_bool2bs started.
Test case tc_asn1_bool2bs finished. Verdict: pass
Execution of control part in module JsonBasicASN1EncDecTest1 finished.
Execution of control part in module JsonBasicAttributeTest started.
Test case tc_attr0_0 started.
Test case tc_attr0_0 finished. Verdict: pass
Test case tc_attr0_1 started.
Test case tc_attr0_1 finished. Verdict: pass
Test case tc_attr1_0 started.
Test case tc_attr1_0 finished. Verdict: pass
Test case tc_attr1_1 started.
Test case tc_attr1_1 finished. Verdict: pass
Test case tc_attr2_0 started.
Test case tc_attr2_0 finished. Verdict: pass
Test case tc_attr2_1 started.
Test case tc_attr2_1 finished. Verdict: pass
Test case tc_attr3_0 started.
Test case tc_attr3_0 finished. Verdict: pass
Test case tc_attr3_1 started.
Test case tc_attr3_1 finished. Verdict: pass
Test case tc_attr4_0 started.
Test case tc_attr4_0 finished. Verdict: pass
Test case tc_attr4_1 started.
Test case tc_attr4_1 finished. Verdict: pass
Execution of control part in module JsonBasicAttributeTest finished.
Execution of control part in module JsonBasicEncDecTest_bs started.
Test case tc_jsonBasic_encdec_integer started.
Test case tc_jsonBasic_encdec_integer finished. Verdict: pass
Test case tc_jsonBasic_encdec_float1 started.
Test case tc_jsonBasic_encdec_float1 finished. Verdict: pass
Test case tc_jsonBasic_encdec_float2 started.
Test case tc_jsonBasic_encdec_float2 finished. Verdict: pass
Test case tc_jsonBasic_encdec_float3 started.
Test case tc_jsonBasic_encdec_float3 finished. Verdict: pass
Test case tc_jsonBasic_encdec_float4 started.
Test case tc_jsonBasic_encdec_float4 finished. Verdict: pass
Test case tc_jsonBasic_encdec_enum started.
Test case tc_jsonBasic_encdec_enum finished. Verdict: pass
Test case tc_jsonBasic_encdec_bool1 started.
Test case tc_jsonBasic_encdec_bool1 finished. Verdict: pass
Test case tc_jsonBasic_encdec_bool2 started.
Test case tc_jsonBasic_encdec_bool2 finished. Verdict: pass
Test case tc_jsonBasic_encdec_bitstring started.
Test case tc_jsonBasic_encdec_bitstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_charstring started.
Test case tc_jsonBasic_encdec_charstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_hexstring started.
Test case tc_jsonBasic_encdec_hexstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_octetstring started.
Test case tc_jsonBasic_encdec_octetstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_ucharstring started.
Test case tc_jsonBasic_encdec_ucharstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_record started.
Test case tc_jsonBasic_encdec_record finished. Verdict: pass
Test case tc_jsonBasic_encdec_set started.
Test case tc_jsonBasic_encdec_set finished. Verdict: pass
Test case tc_jsonBasic_encdec_roi1 started.
Test case tc_jsonBasic_encdec_roi1 finished. Verdict: pass
Test case tc_jsonBasic_encdec_roi2 started.
Test case tc_jsonBasic_encdec_roi2 finished. Verdict: pass
Test case tc_jsonBasic_encdec_soi1 started.
Test case tc_jsonBasic_encdec_soi1 finished. Verdict: pass
Test case tc_jsonBasic_encdec_soi2 started.
Test case tc_jsonBasic_encdec_soi2 finished. Verdict: pass
Test case tc_jsonBasic_encdec_soi3 started.
Test case tc_jsonBasic_encdec_soi3 finished. Verdict: pass
Test case tc_jsonBasic_encdec_union_const started.
Test case tc_jsonBasic_encdec_union_const finished. Verdict: pass
Test case tc_jsonBasic_encdec_union started.
Test case tc_jsonBasic_encdec_union finished. Verdict: pass
Test case tc_jsonBasic_encdec_anytype_i started.
Test case tc_jsonBasic_encdec_anytype_i finished. Verdict: pass
Execution of control part in module JsonBasicEncDecTest_bs finished.
Execution of control part in module JsonBasicEncDecTest_os started.
Test case tc_jsonBasic_encdec_os_integer started.
Test case tc_jsonBasic_encdec_os_integer finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_float started.
Test case tc_jsonBasic_encdec_os_float finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_enum started.
Test case tc_jsonBasic_encdec_os_enum finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_bitstring started.
Test case tc_jsonBasic_encdec_os_bitstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_charstring started.
Test case tc_jsonBasic_encdec_os_charstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_hexstring started.
Test case tc_jsonBasic_encdec_os_hexstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_octetstring started.
Test case tc_jsonBasic_encdec_os_octetstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_ucharstring started.
Test case tc_jsonBasic_encdec_os_ucharstring finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_record started.
Test case tc_jsonBasic_encdec_os_record finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_roi1 started.
Test case tc_jsonBasic_encdec_os_roi1 finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_roi2 started.
Test case tc_jsonBasic_encdec_os_roi2 finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_roi3 started.
Test case tc_jsonBasic_encdec_os_roi3 finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_set started.
Test case tc_jsonBasic_encdec_os_set finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_soi started.
Test case tc_jsonBasic_encdec_os_soi finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_union_const started.
Test case tc_jsonBasic_encdec_os_union_const finished. Verdict: pass
Test case tc_jsonBasic_encdec_os_union started.
Test case tc_jsonBasic_encdec_os_union finished. Verdict: pass
Execution of control part in module JsonBasicEncDecTest_os finished.
Verdict statistics: 0 none (0.00 %), 51 pass (100.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 0 error (0.00 %).
Test execution summary: 51 test cases were executed. Overall verdict: pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment