1.1 --- a/libipc/lib/src/message.c Mon May 06 01:09:30 2024 +0200
1.2 +++ b/libipc/lib/src/message.c Mon May 06 01:14:09 2024 +0200
1.3 @@ -213,7 +213,12 @@
1.4 msg->discarded_items = 0;
1.5 msg->words = 0;
1.6 msg->items = 0;
1.7 +
1.8 + /* Initialise items to be received.
1.9 + NOTE: This does not support item type mixing. */
1.10 +
1.11 msg->import_item = 0;
1.12 + msg->bregs.bdr = 0;
1.13
1.14 /* Message label overriding. */
1.15
1.16 @@ -510,8 +515,16 @@
1.17 if (local)
1.18 return L4_EOK;
1.19
1.20 - err = ipc_message_expect_capability(msg, msg->import_item);
1.21 - msg->import_item += 1;
1.22 + /* Only if the specified item yielded a valid capability, will an allocated
1.23 + have been consumed. Otherwise, the next allocated capability will still be
1.24 + available. */
1.25 +
1.26 + if (l4_is_valid_cap(*ref))
1.27 + {
1.28 + err = ipc_message_expect_capability(msg, msg->import_item);
1.29 + msg->import_item += 1;
1.30 + }
1.31 +
1.32 return err;
1.33 }
1.34