From c5fabf55a03cd573ca2bb50d65d404bcbeade31e Mon Sep 17 00:00:00 2001 From: "Zheng, Gen" Date: Thu, 12 Apr 2018 14:04:23 +0800 Subject: [PATCH] sprintf: bug fix in sprintf implemented code In the case that the copy sz is 0, it is unnecessary to do copy. Signed-off-by: Zheng, Gen Reviewed-by: Chen, Jason Cl Reviewed-by: Yakui, Zhao --- hypervisor/lib/sprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypervisor/lib/sprintf.c b/hypervisor/lib/sprintf.c index 1feb113ea..119129537 100644 --- a/hypervisor/lib/sprintf.c +++ b/hypervisor/lib/sprintf.c @@ -634,7 +634,7 @@ static int charmem(int cmd, const char *s, int sz, void *hnd) n++; } - } else { + } else if (sz > 0) { while (*s && n < sz) { if (n < param->sz - param->wrtn) *p = *s;