nfs4: Fix memory leaks in case of error in ReplyInterpreter::_DecodeAttrs()
This patch fixes CID 991505, 991504, 991502, 991500, 991499, 991496.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
|
|
||||||
#include "Cookie.h"
|
#include "Cookie.h"
|
||||||
@@ -554,6 +555,7 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
|||||||
uint32* bitmap = new(std::nothrow) uint32[bcount];
|
uint32* bitmap = new(std::nothrow) uint32[bcount];
|
||||||
if (bitmap == NULL)
|
if (bitmap == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
ArrayDeleter<uint32> _(bitmap);
|
||||||
|
|
||||||
uint32 attr_count = 0;
|
uint32 attr_count = 0;
|
||||||
for (uint32 i = 0; i < bcount; i++) {
|
for (uint32 i = 0; i < bcount; i++) {
|
||||||
@@ -573,10 +575,8 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
|||||||
XDR::ReadStream stream(const_cast<void*>(ptr), size);
|
XDR::ReadStream stream(const_cast<void*>(ptr), size);
|
||||||
|
|
||||||
AttrValue* values = new(std::nothrow) AttrValue[attr_count];
|
AttrValue* values = new(std::nothrow) AttrValue[attr_count];
|
||||||
if (values == NULL) {
|
if (values == NULL)
|
||||||
delete[] bitmap;
|
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
|
||||||
|
|
||||||
uint32 current = 0;
|
uint32 current = 0;
|
||||||
|
|
||||||
@@ -774,11 +774,13 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
|||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] bitmap;
|
|
||||||
|
|
||||||
*count = attr_count;
|
*count = attr_count;
|
||||||
*attrs = values;
|
*attrs = values;
|
||||||
return str.IsEOF() ? B_BAD_VALUE : B_OK;
|
if (str.IsEOF()) {
|
||||||
|
delete[] values;
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user