Skip to content

Commit

Permalink
Handling null event Data
Browse files Browse the repository at this point in the history
Reason for change: : Handling null event data while appending to or 
                                  updating from a message
Signed-off-by: Netaji Panigrahi [email protected]
  • Loading branch information
NetajiPanigrahi authored Jul 10, 2024
1 parent db9eeba commit 2bb8513
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/rbus/rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ void rbusPropertyList_initFromMessage(rbusProperty_t* prop, rbusMessage msg)

void rbusObject_appendToMessage(rbusObject_t obj, rbusMessage msg)
{
if (obj == NULL)
{
return;
}
int numChild = 0;
rbusObject_t child;

Expand Down Expand Up @@ -818,16 +822,18 @@ void rbusEventData_updateFromMessage(rbusEvent_t* event, rbusFilter_t* filter,
{
char const* name;
int type;
rbusObject_t data;
rbusObject_t data = NULL;
int hasFilter = false;
int hasEventData = false;

rbusMessage_GetString(msg, (char const**) &name);
rbusMessage_GetInt32(msg, (int*) &type);
#if DEBUG_SERIALIZER
RBUSLOG_INFO("> event pop name=%s type=%d", name, type);
#endif

rbusObject_initFromMessage(&data, msg);
rbusMessage_GetInt32(msg, &hasEventData);
if (hasEventData)
rbusObject_initFromMessage(&data, msg);

rbusMessage_GetInt32(msg, &hasFilter);
if(hasFilter)
Expand All @@ -851,7 +857,16 @@ void rbusEventData_appendToMessage(rbusEvent_t* event, rbusFilter_t filter,
#if DEBUG_SERIALIZER
RBUSLOG_INFO("> event add name=%s type=%d", event->name, event->type);
#endif
rbusObject_appendToMessage(event->data, msg);
/*hasEventData*/
if (event->data)
{
rbusMessage_SetInt32(msg, 1);
rbusObject_appendToMessage(event->data, msg);
}
else
{
rbusMessage_SetInt32(msg, 0);
}
if(filter)
{
rbusMessage_SetInt32(msg, 1);
Expand Down

0 comments on commit 2bb8513

Please sign in to comment.