From 27bbf04ac6035b05535d9789885e02d7ebfa2263 Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Thu, 29 Dec 2011 15:39:14 +0000 Subject: [PATCH] add more parameters checking in message queue git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1888 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- src/ipc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ipc.c b/src/ipc.c index baacd771f..a61b5c1ee 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -34,6 +34,7 @@ * 2010-04-20 Bernard move memcpy outside interrupt disable in mq * 2010-10-26 yi.qiu add module support in rt_mp_delete and rt_mq_delete * 2010-11-10 Bernard add IPC reset command implementation. + * 2011-12-18 Bernard add more parameter checking in message queue */ #include @@ -1804,6 +1805,10 @@ rt_err_t rt_mq_send(rt_mq_t mq, void *buffer, rt_size_t size) register rt_ubase_t temp; struct rt_mq_message *msg; + RT_ASSERT(mq != RT_NULL); + RT_ASSERT(buffer != RT_NULL); + RT_ASSERT(size != 0); + /* greater than one message size */ if (size > mq->msg_size) return -RT_ERROR; @@ -1885,6 +1890,10 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, void *buffer, rt_size_t size) register rt_ubase_t temp; struct rt_mq_message *msg; + RT_ASSERT(mq != RT_NULL); + RT_ASSERT(buffer != RT_NULL); + RT_ASSERT(size != 0); + /* greater than one message size */ if (size > mq->msg_size) return -RT_ERROR; @@ -1963,6 +1972,10 @@ rt_err_t rt_mq_recv(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout struct rt_mq_message *msg; rt_uint32_t tick_delta; + RT_ASSERT(mq != RT_NULL); + RT_ASSERT(buffer != RT_NULL); + RT_ASSERT(size != 0); + /* initialize delta tick */ tick_delta = 0; /* get current thread */