From 0f0ff1eec0cc52cb492ee1820d434472276d54c1 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 12 Dec 2006 20:44:53 +0000 Subject: [PATCH] Fix for when size=1. --- src/libCom/osi/os/vxWorks/osdStdio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libCom/osi/os/vxWorks/osdStdio.c b/src/libCom/osi/os/vxWorks/osdStdio.c index 8f3a4c168..219cdc5e2 100644 --- a/src/libCom/osi/os/vxWorks/osdStdio.c +++ b/src/libCom/osi/os/vxWorks/osdStdio.c @@ -24,13 +24,14 @@ static STATUS outRoutine(char *buffer, int nchars, int outarg) { int free = poutStr->free; int len; - if(free<=1) { /*let fioFormatV continue to count length*/ + if (free < 1) { /*let fioFormatV continue to count length*/ return OK; + } else if (free > 1) { + len = min(free-1, nchars); + strncpy(poutStr->str, buffer, len); + poutStr->str += len; + poutStr->free -= len; } - len = min(free-1, nchars); - strncpy(poutStr->str, buffer, len); - poutStr->str += len; - poutStr->free -= len; /*make sure final string is null terminated*/ *poutStr->str = 0; return OK;