Skip to content

Commit

Permalink
check the malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
p-avital committed Oct 13, 2023
1 parent d421206 commit 19e694f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,12 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z
wild -= 1;
size_t len = wild - keyexpr._suffix;
suffix = z_malloc(len + 1);
memcpy(suffix, keyexpr._suffix, len);
suffix[len] = 0;
keyexpr._suffix = suffix;
_z_keyexpr_set_owns_suffix(&keyexpr, false);
if (suffix != NULL) {
memcpy(suffix, keyexpr._suffix, len);
suffix[len] = 0;
keyexpr._suffix = suffix;
_z_keyexpr_set_owns_suffix(&keyexpr, false);
}
}
uint16_t id = _z_declare_resource(zs._val, keyexpr);
key = _z_rid_with_suffix(id, wild);
Expand Down

0 comments on commit 19e694f

Please sign in to comment.