<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 8, 2023 at 3:47 PM Chris Johns <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 9/3/2023 5:40 am, Kinsey Moore wrote:<br>
> Casting the node returned by rtems_chain_head is incorrect. That node is<br>
> owned by the control structure and use of it post-cast could cause<br>
> memory corruption.<br>
> ---<br>
>  c-user/chains.rst | 4 ++++<br>
>  1 file changed, 4 insertions(+)<br>
> <br>
> diff --git a/c-user/chains.rst b/c-user/chains.rst<br>
> index f518ef4..e791d10 100644<br>
> --- a/c-user/chains.rst<br>
> +++ b/c-user/chains.rst<br>
> @@ -193,6 +193,10 @@ placed on another chain:<br>
>          rtems_chain_initialize_empty (out);<br>
>  <br>
>          node = rtems_chain_head (chain);<br>
> +<br>
> +        /* The node returned by rtems_chain_head() is owned by the chain */<br>
> +        node = node->next;<br>
<br>
 node = rtems_chain_next (node);  ?<br></blockquote><div><br></div><div>node->next is used slightly further down in the example, but I can change it to rtems_chain_next for both if you prefer. </div><div><br></div><div>Kinsey<br></div></div></div>