Menu

#1053 gsoap 2.8.30 broke array serialization

v1.0 (example)
closed-works-for-me
None
5
2016-05-04
2016-05-03
No

Given this snippet:

struct user {
    unsigned int id;
};
struct userArray {
    unsigned int __size;
    struct user *__ptr;
};

as input to soapcpp2 -z1 test.h, 2.8.22 and 2.8.30 generate different output. In particular, 2.8.22 walks through the array:

SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_userArray(struct soap *soap, const struct userArray *a)
{
        (void)soap; (void)a; /* appease -Wall -Werror */
#ifndef WITH_NOIDREF
        if (a->__ptr)
        {       int i;
                for (i = 0; i < a->__size; i++)
                {
                        soap_embedded(soap, a->__ptr + i, SOAP_TYPE_user);
                        soap_serialize_user(soap, a->__ptr + i);
                }
        }
#endif
}

2.8.30 no longer does that.

SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_userArray(struct soap *soap, const struct userArray *a)
{
        (void)soap; (void)a; /* appease -Wall -Werror */
#ifndef WITH_NOIDREF
        soap_serialize_PointerTouser(soap, &a->__ptr);
#endif
}

It appears I can work around it by changing to int or size_t, but gsoap changing behavior just like that is really bad :-(

Discussion

  • Robert van Engelen

    You should not use unsigned int for the size (see databinding documentation, so the corrected definition is:

    struct userArray {
        struct user *__ptr;
        int __size;
     };
    
     
  • Robert van Engelen

    • status: open --> closed-works-for-me
    • assigned_to: Robert van Engelen
     

Log in to post a comment.