--- ecos_web_cvs/ecos/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx	2009-07-22 20:49:55.593750000 +0200
+++ ecos/ecos/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx	2009-07-30 16:28:11.437989200 +0200
@@ -208,14 +208,12 @@
          */
 #define PRINT(ptr, len)                                                      \
 CYG_MACRO_START                                                              \
-    cyg_ucount32 length = MIN( (cyg_ucount32) len, n - ret - 1);             \
-    if (((Cyg_OutputStream *)stream)->write( (const cyg_uint8 *)ptr,         \
+    if ((size_t)(ret + 1) < n) {                                             \
+        cyg_ucount32 length = MIN( (cyg_ucount32) len, n - ret - 1);         \
+        if (((Cyg_OutputStream *)stream)->write( (const cyg_uint8 *)ptr,     \
                                             length, &length ))               \
-        goto error;                                                          \
-    if (length < (cyg_ucount32)len) {                                        \
-        ret += length;                                                       \
-        goto done;                                                           \
-    }                                                                        \
+            goto error;                                                      \
+	}                                                                        \
 CYG_MACRO_END
 
 
@@ -276,7 +274,7 @@
                         PRINT(cp, y);
                         ret += y;
                 }
-                if ((x <= 0) || (ret >= (int)n))  // @@@ this check with n isn't good enough
+                if (x <= 0)
                         goto done;
                 fmt++;          /* skip over '%' */
 
