mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 22:20:01 +08:00
Fixed NULL pointer use in tmpfs.
This commit is contained in:
committed by
Xiang Xiao
parent
403c657f42
commit
a0918d6d5e
+18
-4
@@ -1496,8 +1496,15 @@ static ssize_t tmpfs_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
/* Copy data from the memory object to the user buffer */
|
||||
|
||||
memcpy(buffer, &tfo->tfo_data[startpos], nread);
|
||||
filep->f_pos += nread;
|
||||
if (tfo->tfo_data != NULL)
|
||||
{
|
||||
memcpy(buffer, &tfo->tfo_data[startpos], nread);
|
||||
filep->f_pos += nread;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGASSERT(tfo->tfo_size == 0 && nread == 0);
|
||||
}
|
||||
|
||||
/* Release the lock on the file */
|
||||
|
||||
@@ -1553,8 +1560,15 @@ static ssize_t tmpfs_write(FAR struct file *filep, FAR const char *buffer,
|
||||
|
||||
/* Copy data from the memory object to the user buffer */
|
||||
|
||||
memcpy(&tfo->tfo_data[startpos], buffer, nwritten);
|
||||
filep->f_pos += nwritten;
|
||||
if (tfo->tfo_data != NULL)
|
||||
{
|
||||
memcpy(&tfo->tfo_data[startpos], buffer, nwritten);
|
||||
filep->f_pos += nwritten;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGASSERT(tfo->tfo_size == 0 && nwritten == 0);
|
||||
}
|
||||
|
||||
/* Release the lock on the file */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user