Skip to content

Commit 283c3c0

Browse files
committed
client session BUGFIX check all errors when creating RPCs
Fixes #283
1 parent 623d59e commit 283c3c0

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/session_client.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,20 +2654,32 @@ nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_
26542654

26552655
data = lyd_new(NULL, mod, "kill-session");
26562656
sprintf(str, "%u", rpc_k->sid);
2657-
lyd_new_leaf(data, mod, "session-id", str);
2657+
node = lyd_new_leaf(data, mod, "session-id", str);
2658+
if (!node) {
2659+
lyd_free(data);
2660+
return NC_MSG_ERROR;
2661+
}
26582662
break;
26592663

26602664
case NC_RPC_COMMIT:
26612665
rpc_com = (struct nc_rpc_commit *)rpc;
26622666

26632667
data = lyd_new(NULL, mod, "commit");
26642668
if (rpc_com->confirmed) {
2665-
lyd_new_leaf(data, mod, "confirmed", NULL);
2669+
node = lyd_new_leaf(data, mod, "confirmed", NULL);
2670+
if (!node) {
2671+
lyd_free(data);
2672+
return NC_MSG_ERROR;
2673+
}
26662674
}
26672675

26682676
if (rpc_com->confirm_timeout) {
26692677
sprintf(str, "%u", rpc_com->confirm_timeout);
2670-
lyd_new_leaf(data, mod, "confirm-timeout", str);
2678+
node = lyd_new_leaf(data, mod, "confirm-timeout", str);
2679+
if (!node) {
2680+
lyd_free(data);
2681+
return NC_MSG_ERROR;
2682+
}
26712683
}
26722684

26732685
if (rpc_com->persist) {

0 commit comments

Comments
 (0)