fixed invalid vasnprintf() calls

This commit is contained in:
git@daemon.de
2014-03-10 17:00:31 +01:00
parent 770d464dd1
commit c3070242a8
3 changed files with 32 additions and 18 deletions

View File

@@ -19,10 +19,12 @@
You can contact me by mail: <tlinden AT cpan DOT org>.
*/
#define _GNU_SOURCE /* vasprintf() linux */
#include "defines.h"
#include "platform.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -38,11 +40,14 @@ void fatal(const char * fmt, ...) {
va_list ap;
va_start(ap, fmt);
vasprintf(&PCP_ERR, fmt, ap);
va_end(ap);
PCP_ERRSET = 1;
if(vasprintf(&PCP_ERR, fmt, ap) >= 0) {
va_end(ap);
PCP_ERRSET = 1;
}
else {
fprintf(stderr, "Could not store fatal error message %s!\n", fmt);
PCP_ERRSET = 1;
}
}
void fatals_reset() {
@@ -51,7 +56,7 @@ void fatals_reset() {
void fatals_ifany() {
if(PCP_ERRSET == 1) {
fprintf(stderr, PCP_ERR);
fprintf(stderr, "%s", PCP_ERR);
if(errno) {
fprintf(stderr, "Error: %s\n", strerror(errno));
}