mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Avoid crash on OOM in virbuftest
The virbuftest code did not check virBufferError before accessing the buffer contents, resulting in a crash on OOM conditions. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
0bbeafc768
commit
0b30d3458a
@ -108,6 +108,10 @@ static int testBufAutoIndent(const void *data ATTRIBUTE_UNUSED)
|
||||
}
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
virBufferAddLit(buf, "1");
|
||||
if (virBufferError(buf)) {
|
||||
TEST_ERROR("Buffer had error");
|
||||
return -1;
|
||||
}
|
||||
if (STRNEQ(virBufferCurrentContent(buf), " 1")) {
|
||||
TEST_ERROR("Wrong content");
|
||||
ret = -1;
|
||||
@ -134,6 +138,11 @@ static int testBufAutoIndent(const void *data ATTRIBUTE_UNUSED)
|
||||
virBufferEscapeShell(buf, " 11");
|
||||
virBufferAddChar(buf, '\n');
|
||||
|
||||
if (virBufferError(buf)) {
|
||||
TEST_ERROR("Buffer had error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = virBufferContentAndReset(buf);
|
||||
if (!result || STRNEQ(result, expected)) {
|
||||
virtTestDifference(stderr, expected, result);
|
||||
@ -166,6 +175,11 @@ static int testBufTrim(const void *data ATTRIBUTE_UNUSED)
|
||||
virBufferTrim(buf, "b,,", 1);
|
||||
virBufferTrim(buf, ",", -1);
|
||||
|
||||
if (virBufferError(buf)) {
|
||||
TEST_ERROR("Buffer had error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = virBufferContentAndReset(buf);
|
||||
if (!result || STRNEQ(result, expected)) {
|
||||
virtTestDifference(stderr, expected, result);
|
||||
|
Loading…
Reference in New Issue
Block a user