mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Fix possible NULL reference reported by Coverity.
this->input is set to NULL when the read input goes to EOF but it was possible that this->input could be used again in a subsequent loop, according to Coverity. In fact this would really only be a problem if EOF suddenly went back to false, which is not allowed. However, checking this->input is cheaper than calling ioReadEofDriver() driver on each loop so this change makes sense as an optimization and it makes Coverity happy, too.
This commit is contained in:
parent
f764953b70
commit
e421cf9dd3
@ -138,20 +138,23 @@ ioReadInternal(IoRead *this, Buffer *buffer, bool block)
|
||||
else
|
||||
{
|
||||
// Read if not EOF
|
||||
if (!ioReadEofDriver(this))
|
||||
if (this->input != NULL)
|
||||
{
|
||||
bufUsedZero(this->input);
|
||||
if (!ioReadEofDriver(this))
|
||||
{
|
||||
bufUsedZero(this->input);
|
||||
|
||||
// If blocking then limit the amount of data requested
|
||||
if (ioReadBlock(this) && bufRemains(this->input) > bufRemains(buffer))
|
||||
bufLimitSet(this->input, bufRemains(buffer));
|
||||
// If blocking then limit the amount of data requested
|
||||
if (ioReadBlock(this) && bufRemains(this->input) > bufRemains(buffer))
|
||||
bufLimitSet(this->input, bufRemains(buffer));
|
||||
|
||||
this->interface.read(this->driver, this->input, block);
|
||||
bufLimitClear(this->input);
|
||||
this->interface.read(this->driver, this->input, block);
|
||||
bufLimitClear(this->input);
|
||||
}
|
||||
// Set input to NULL and flush (no need to actually free the buffer here as it will be freed with the mem context)
|
||||
else
|
||||
this->input = NULL;
|
||||
}
|
||||
// Set input to NULL and flush (no need to actually free the buffer here as it will be freed with the mem context)
|
||||
else
|
||||
this->input = NULL;
|
||||
|
||||
// Process the input buffer (or flush if NULL)
|
||||
if (this->input == NULL || bufUsed(this->input) > 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user