aboutsummaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authorokan2020-01-22 19:58:35 +0000
committerWynn Wolf Arbor2020-03-18 14:28:38 +0100
commitae986902cfc1846881bb4341f33c0e14b495c309 (patch)
treeca4e99c73a46dcd34d3dc8afb6418ac2b2b8b562 /xmalloc.c
parent178643ac5ef7fc3d2dbf28352edb566daefee288 (diff)
downloadcwm-ae986902cfc1846881bb4341f33c0e14b495c309.tar.gz
add, then use, xvasprintf, checking for appropriate return.
Diffstat (limited to '')
-rw-r--r--xmalloc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 21a65d7..ab5719c 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xmalloc.c,v 1.15 2015/03/28 23:12:47 okan Exp $
+ * $OpenBSD: xmalloc.c,v 1.16 2020/01/22 19:58:35 okan Exp $
*/
#include <sys/types.h>
@@ -91,11 +91,20 @@ xasprintf(char **ret, const char *fmt, ...)
int i;
va_start(ap, fmt);
- i = vasprintf(ret, fmt, ap);
+ i = xvasprintf(ret, fmt, ap);
va_end(ap);
- if (i < 0 || *ret == NULL)
- err(1, "asprintf");
+ return(i);
+}
+
+int
+xvasprintf(char **ret, const char *fmt, va_list ap)
+{
+ int i;
+
+ i = vasprintf(ret, fmt, ap);
+ if (i == -1)
+ err(1, "vasprintf");
return(i);
}