Skip to content

Commit

Permalink
cancel prefix declaration if allocating suffix failed in subscriber d…
Browse files Browse the repository at this point in the history
…eclaration
  • Loading branch information
p-avital committed Oct 17, 2023
1 parent 19e694f commit db2ac4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z
_z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr);
if (r == NULL) {
char *wild = strpbrk(keyexpr._suffix, "*$");
_Bool do_keydecl = true;
if (wild != NULL && wild != keyexpr._suffix) {
wild -= 1;
size_t len = wild - keyexpr._suffix;
Expand All @@ -831,10 +832,14 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z
suffix[len] = 0;
keyexpr._suffix = suffix;
_z_keyexpr_set_owns_suffix(&keyexpr, false);
} else {
do_keydecl = false;
}
}
uint16_t id = _z_declare_resource(zs._val, keyexpr);
key = _z_rid_with_suffix(id, wild);
if (do_keydecl) {
uint16_t id = _z_declare_resource(zs._val, keyexpr);
key = _z_rid_with_suffix(id, wild);
}
}
#if Z_FEATURE_MULTICAST_TRANSPORT == 1
}
Expand Down
6 changes: 3 additions & 3 deletions zenohpico.pc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
prefix=/usr/local
prefix=/var/empty/local

Name: zenohpico
Description:
URL:
Version: 0.11.20231012dev
Version: 0.11.20231017dev
Cflags: -I${prefix}/include
Libs: -L${prefix}/lib -lzenohpico
Libs: -L${prefix}/lib64 -lzenohpico

0 comments on commit db2ac4c

Please sign in to comment.