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 <gen.zheng@intel.com>
Reviewed-by: Chen, Jason Cl <jason.cj.chen@intel.com>
Reviewed-by: Yakui, Zhao <yakui.zhao@intel.com>
This commit is contained in:
Zheng, Gen 2018-04-12 14:04:23 +08:00 committed by Jack Ren
parent 9b37e1464c
commit c5fabf55a0
1 changed files with 1 additions and 1 deletions

View File

@ -634,7 +634,7 @@ static int charmem(int cmd, const char *s, int sz, void *hnd)
n++; n++;
} }
} else { } else if (sz > 0) {
while (*s && n < sz) { while (*s && n < sz) {
if (n < param->sz - param->wrtn) if (n < param->sz - param->wrtn)
*p = *s; *p = *s;