Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 253da23

Browse files
authored
Check allocation of requester and replier (#60) (#63)
Signed-off-by: Stephen Brawner <[email protected]>
1 parent 2cb8042 commit 253da23

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rosidl_typesupport_connext_cpp/resource/srv__type_support.cpp.em

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ void * create_requester__@(service.namespaced_type.name)(
151151
requester_params.datawriter_qos(*datawriter_qos);
152152

153153
RequesterType * requester = static_cast<RequesterType *>(_allocator(sizeof(RequesterType)));
154+
if (NULL == requester) {
155+
fprintf(stderr, "failed to allocate memory for requester\n");
156+
return NULL;
157+
}
154158
try {
155159
new (requester) RequesterType(requester_params);
156160
} catch (...) {
@@ -255,6 +259,10 @@ void * create_replier__@(service.namespaced_type.name)(
255259
replier_params.datawriter_qos(*datawriter_qos);
256260

257261
ReplierType * replier = static_cast<ReplierType *>(_allocator(sizeof(ReplierType)));
262+
if (NULL == replier) {
263+
fprintf(stderr, "failed to allocate memory for replier\n");
264+
return NULL;
265+
}
258266
try {
259267
new (replier) ReplierType(replier_params);
260268
} catch (...) {

0 commit comments

Comments
 (0)