esa / asn1scc

ASN1SCC: An open source ASN.1 compiler for embedded systems
https://www.thanassis.space/asn1.html
Other
272 stars 58 forks source link

Recursive _IsConstraintValid() #263

Closed escmmo closed 1 year ago

escmmo commented 1 year ago

asn1scc version 4.5.0.4 The compiler produces an _IsContraintValid() function that calls itself unconditionally:

flag T_STRUCT_member_IsConstraintValid(const T_STRUCT_member* pVal, int* pErrCode)
{
    flag ret = TRUE;
    ret = T_STRUCT_member_IsConstraintValid(pVal, pErrCode);
    if (ret) {
        ret = ((*(pVal)) == 100UL);
        *pErrCode = ret ? 0 :  ERR_T_STRUCT_MEMBER_2_2; 
    }   /*COVERAGE_IGNORE*/

        return ret;
}

The .asn definition that generates this is:

T-uint32 ::= INTEGER(0..4294967295)

T-SOME-TYPE ::= T-uint32

T-STRUCT ::= SEQUENCE
{
    member  T-SOME-TYPE (100)
}

The key points which trigger this behavior are:

If member is defined as T-uint32 instead, or no value is specified, no recursive function is created.

maxime-esa commented 1 year ago

Reproduced. We are looking into it, thanks for reporting.

usr3-1415 commented 1 year ago

Issue Fixed. Thanks for reporting the issue.