提交 a93eb09a 编写于 作者: D Daniel P. Berrange

Avoid crash on OOM in virnetmessagetest

The virnetmessagetest code did not check for failure to
allocate the message object. This lead to a crash on OOM
in the test suite.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 5e67ed42
...@@ -327,6 +327,9 @@ static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED) ...@@ -327,6 +327,9 @@ static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED)
}; };
int ret = -1; int ret = -1;
if (!msg)
return -1;
msg->bufferLength = 4; msg->bufferLength = 4;
if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0)
goto cleanup; goto cleanup;
...@@ -476,6 +479,9 @@ static int testMessagePayloadStreamEncode(const void *args ATTRIBUTE_UNUSED) ...@@ -476,6 +479,9 @@ static int testMessagePayloadStreamEncode(const void *args ATTRIBUTE_UNUSED)
}; };
int ret = -1; int ret = -1;
if (!msg)
return -1;
msg->header.prog = 0x11223344; msg->header.prog = 0x11223344;
msg->header.vers = 0x01; msg->header.vers = 0x01;
msg->header.proc = 0x666; msg->header.proc = 0x666;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册