diff --git a/utility/rtos_compatibility_layers/posix/px_mq_send.c b/utility/rtos_compatibility_layers/posix/px_mq_send.c index d4702808..f641419a 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_send.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_send.c @@ -167,7 +167,16 @@ ULONG msg[TX_POSIX_MESSAGE_SIZE]; if (temp1 != TX_SUCCESS) { - posix_internal_error(9999); + posix_internal_error(9999); + + /* posix_internal_error() does not return today, but do not depend on + that: bp is indeterminate here, so falling through would copy + msg_len bytes through an unset pointer. */ + posix_errno = ENOMEM; + posix_set_pthread_errno(ENOMEM); + + /* Return ERROR. */ + return(ERROR); } /* Got the memory , Setup source and destination pointers Cast them in UCHAR as message length is in bytes. */ diff --git a/utility/rtos_compatibility_layers/posix/px_pth_init.c b/utility/rtos_compatibility_layers/posix/px_pth_init.c index 5d2f36ad..a2f97be7 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_init.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_init.c @@ -538,7 +538,13 @@ POSIX_TCB *p_tcb; if (!thread_ptr) { /* Not called from a thread - error! */ - posix_internal_error(222); + posix_internal_error(222); + + /* posix_internal_error() does not return today, but do not depend on + that: posix_thread2tcb() hands back NULL for this input and the read + below would dereference it. A pthread ID is the address of the TCB, + so zero is never a valid one. */ + return((pthread_t) 0); } /* Get the TCB for this pthread */