mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 20:53:46 +00:00
tools: fix variable argument list read without ending with va_end
va_end() was not getting called under certain condition after the va_start() function call taking the va_list Tracked-On: #3396 Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com> Acked-by: Gang Chen <gang.c.chen@intel.com>
This commit is contained in:
parent
bc90db46fc
commit
1394758d69
@ -21,10 +21,14 @@ void debug_log(const int level, const char *func, const int line, ...)
|
|||||||
|
|
||||||
va_start(args, line);
|
va_start(args, line);
|
||||||
fmt = va_arg(args, char *);
|
fmt = va_arg(args, char *);
|
||||||
if (!fmt)
|
if (!fmt) {
|
||||||
|
va_end(args);
|
||||||
return;
|
return;
|
||||||
if (vasprintf(&msg, fmt, args) == -1)
|
}
|
||||||
|
if (vasprintf(&msg, fmt, args) == -1) {
|
||||||
|
va_end(args);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (asprintf(&head, "<%-20s%5d>: ", func, line) == -1) {
|
if (asprintf(&head, "<%-20s%5d>: ", func, line) == -1) {
|
||||||
|
@ -36,11 +36,11 @@ static void loginfo(int fd, const char *fmt, ...)
|
|||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
len = vasprintf(&buf, fmt, ap);
|
len = vasprintf(&buf, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
LOGE("write to buf failed\n");
|
LOGE("write to buf failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
ret = write(fd, buf, len);
|
ret = write(fd, buf, len);
|
||||||
if (ret != len) {
|
if (ret != len) {
|
||||||
|
Loading…
Reference in New Issue
Block a user