Changeset 19219


Ignore:
Timestamp:
03/24/15 12:03:49 (10 years ago)
Author:
Eric.Larour
Message:

CHG: fixing a potential segfault occurence when the marshalled dynamic array is actually a NULL pointer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

    r19215 r19219  
    1717                memcpy(*pmarshalled_data,&enum_type,sizeof(int));\
    1818                *pmarshalled_data+=sizeof(int);\
    19                 *pmarshalled_data_size+=sizeof(int);\
    2019        }\
    2120        else if(marshall_direction==MARSHALLING_SIZE){\
     
    2322        }\
    2423        else if(marshall_direction==MARSHALLING_BACKWARD){\
     24                *pmarshalled_data+=sizeof(int);\
    2525        }\
    2626        else _error_("Wrong direction during the Marshall process");\
     
    3232                memcpy(*pmarshalled_data,&FIELD,sizeof(FIELD));\
    3333                *pmarshalled_data+=sizeof(FIELD);\
    34                 *pmarshalled_data_size+=sizeof(FIELD);\
    3534        }\
    3635        else if(marshall_direction==MARSHALLING_SIZE){\
     
    4948                memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
    5049                *pmarshalled_data+=SIZE*sizeof(TYPE);\
    51                 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
    5250        }\
    5351        else if(marshall_direction==MARSHALLING_SIZE){\
     
    6361#define MARSHALLING_DYNAMIC(FIELD,TYPE,SIZE) \
    6462        \
    65         if(marshall_direction==MARSHALLING_FORWARD){\
    66                 memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
    67                 *pmarshalled_data+=SIZE*sizeof(TYPE);\
    68                 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
    69         }\
    70         else if(marshall_direction==MARSHALLING_SIZE){\
    71                 *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
    72         }\
    73         else if(marshall_direction==MARSHALLING_BACKWARD){\
    74                 FIELD=xNew<TYPE>(SIZE);\
    75                 memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\
    76                 *pmarshalled_data+=SIZE*sizeof(TYPE);\
    77         }\
    78         else _error_("Wrong direction during the Marshall process");
     63        {\
     64                bool field_null=true;\
     65                if (FIELD)field_null=false;\
     66                MARSHALLING(field_null);\
     67                \
     68                if(!field_null){\
     69                        if(marshall_direction==MARSHALLING_FORWARD){\
     70                                        memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
     71                                        *pmarshalled_data+=SIZE*sizeof(TYPE);\
     72                        }\
     73                        else if(marshall_direction==MARSHALLING_SIZE){\
     74                                *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
     75                        }\
     76                        else if(marshall_direction==MARSHALLING_BACKWARD){\
     77                                FIELD=xNew<TYPE>(SIZE);\
     78                                memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\
     79                                *pmarshalled_data+=SIZE*sizeof(TYPE);\
     80                        }\
     81                        else _error_("Wrong direction during the Marshall process");\
     82                }\
     83        }
    7984
    8085#endif 
Note: See TracChangeset for help on using the changeset viewer.