Skip to content

Commit db2ac4c

Browse files
committed
cancel prefix declaration if allocating suffix failed in subscriber declaration
1 parent 19e694f commit db2ac4c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/api/api.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z
822822
_z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr);
823823
if (r == NULL) {
824824
char *wild = strpbrk(keyexpr._suffix, "*$");
825+
_Bool do_keydecl = true;
825826
if (wild != NULL && wild != keyexpr._suffix) {
826827
wild -= 1;
827828
size_t len = wild - keyexpr._suffix;
@@ -831,10 +832,14 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z
831832
suffix[len] = 0;
832833
keyexpr._suffix = suffix;
833834
_z_keyexpr_set_owns_suffix(&keyexpr, false);
835+
} else {
836+
do_keydecl = false;
834837
}
835838
}
836-
uint16_t id = _z_declare_resource(zs._val, keyexpr);
837-
key = _z_rid_with_suffix(id, wild);
839+
if (do_keydecl) {
840+
uint16_t id = _z_declare_resource(zs._val, keyexpr);
841+
key = _z_rid_with_suffix(id, wild);
842+
}
838843
}
839844
#if Z_FEATURE_MULTICAST_TRANSPORT == 1
840845
}

zenohpico.pc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
prefix=/usr/local
1+
prefix=/var/empty/local
22

33
Name: zenohpico
44
Description:
55
URL:
6-
Version: 0.11.20231012dev
6+
Version: 0.11.20231017dev
77
Cflags: -I${prefix}/include
8-
Libs: -L${prefix}/lib -lzenohpico
8+
Libs: -L${prefix}/lib64 -lzenohpico

0 commit comments

Comments
 (0)