Skip to content

Commit 19e694f

Browse files
committed
check the malloc
1 parent d421206 commit 19e694f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/api/api.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,12 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z
826826
wild -= 1;
827827
size_t len = wild - keyexpr._suffix;
828828
suffix = z_malloc(len + 1);
829-
memcpy(suffix, keyexpr._suffix, len);
830-
suffix[len] = 0;
831-
keyexpr._suffix = suffix;
832-
_z_keyexpr_set_owns_suffix(&keyexpr, false);
829+
if (suffix != NULL) {
830+
memcpy(suffix, keyexpr._suffix, len);
831+
suffix[len] = 0;
832+
keyexpr._suffix = suffix;
833+
_z_keyexpr_set_owns_suffix(&keyexpr, false);
834+
}
833835
}
834836
uint16_t id = _z_declare_resource(zs._val, keyexpr);
835837
key = _z_rid_with_suffix(id, wild);

0 commit comments

Comments
 (0)