Skip to content

Commit

Permalink
Handle error in parsing tree during handle_watch
Browse files Browse the repository at this point in the history
Handle the unlikely case that the rpc_msg_decode_tree fails to build a
tree.
  • Loading branch information
blairsteven authored and carlgsmith committed Sep 20, 2024
1 parent a253464 commit 012c202
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apteryx.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,16 @@ handle_watch (rpc_message msg)
return true;
}

root = break_up_trunk(rpc_msg_decode_tree (msg));
root = rpc_msg_decode_tree (msg);
if (!root)
{
DEBUG ("WATCH[%"PRIu64"]: unable to parse tree\n", ref);
/* Not much we can do but pretend we completed the callback */
rpc_msg_reset (msg);
return true;
}

root = break_up_trunk(root);
/* Replace NULL end nodes with "" */
g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, replace_null_with_empty_string, NULL);

Expand Down

0 comments on commit 012c202

Please sign in to comment.