X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/812b526d127c6657e571db8b33a58137af6709cd..c0f84b88cab9518d29900e02a9fb67776820e902:/lib/asprintf.c diff --git a/lib/asprintf.c b/lib/asprintf.c index 5400339..44be789 100644 --- a/lib/asprintf.c +++ b/lib/asprintf.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2004-2008 Richard Kettlewell + * Copyright (C) 2004-2009 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +24,10 @@ #include #include "printf.h" +#include "log.h" #include "sink.h" #include "mem.h" #include "vector.h" -#include "log.h" /** @brief vasprintf() workalike without encoding errors * @@ -38,11 +38,15 @@ int byte_vasprintf(char **ptrp, const char *fmt, va_list ap) { + struct sink *s; struct dynstr d; int n; dynstr_init(&d); - if((n = byte_vsinkprintf(sink_dynstr(&d), fmt, ap)) >= 0) { + s = sink_dynstr(&d); + n = byte_vsinkprintf(s, fmt, ap); + xfree(s); + if(n >= 0) { dynstr_terminate(&d); *ptrp = d.vec; } @@ -99,7 +103,7 @@ int byte_xvasprintf(char **ptrp, int n; if((n = byte_vasprintf(ptrp, fmt, ap)) < 0) - fatal(errno, "error calling byte_vasprintf"); + disorder_fatal(errno, "error calling byte_vasprintf"); return n; }