Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2007-03-12 23:30:08 +0300
committerJeff Johnston <jjohnstn@redhat.com>2007-03-12 23:30:08 +0300
commit99304ce6c4067c1ad11d9c4723580cb09bf1d853 (patch)
tree036546660dab37a67da4adc69fbe41610e64fdf8 /newlib/libc/stdio/vasiprintf.c
parent9c28809c0f505ea1969523aad89b3a7df045bb7c (diff)
2007-03-12 Eric Blake <ebb9@byu.net>
* libc/stdio/fvwrite.c (__sfvwrite_r): Fix reentrancy. * libc/stdio/vasprintf.c (vasprintf, _vasprintf_r): Pass failed allocation to caller. * libc/stdio/asprintf.c (_asprintf_r, asprintf): Likewise. * libc/stdio/asiprintf.c (_asiprintf_r, asiprintf): Likewise. * libc/stdio/vasiprintf.c (vasiprintf, _vasiprintf_r): Likewise.
Diffstat (limited to 'newlib/libc/stdio/vasiprintf.c')
-rw-r--r--newlib/libc/stdio/vasiprintf.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c
index 721d6fb29..72aa19d11 100644
--- a/newlib/libc/stdio/vasiprintf.c
+++ b/newlib/libc/stdio/vasiprintf.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990 The Regents of the University of California.
+ * Copyright (c) 1990, 2007 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
@@ -46,8 +46,11 @@ _DEFUN(vasiprintf, (strp, fmt, ap),
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
ret = _vfiprintf_r (_REENT, &f, fmt, ap);
- *f._p = 0;
- *strp = f._bf._base;
+ if (ret >= 0)
+ {
+ *f._p = 0;
+ *strp = f._bf._base;
+ }
return ret;
}
@@ -68,8 +71,10 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap),
f._bf._size = f._w = 0;
f._file = -1; /* No file. */
ret = _vfiprintf_r (ptr, &f, fmt, ap);
- *f._p = 0;
- *strp = f._bf._base;
+ if (ret >= 0)
+ {
+ *f._p = 0;
+ *strp = f._bf._base;
+ }
return ret;
}
-