]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ansi.c
Handle encoding errors for platform_vasprintf
[xonotic/gmqcc.git] / ansi.c
diff --git a/ansi.c b/ansi.c
index 3cf4508a31f604363b4609b714ccc2506dbc938d..e377424e035014a4560660609138485e1fc5f475 100644 (file)
--- a/ansi.c
+++ b/ansi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2013
+ * Copyright (C) 2012, 2013, 2014
  *     Dale Weiler
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -62,6 +62,9 @@ int platform_vasprintf(char **dat, const char *fmt, va_list args) {
     len = vsnprintf(buf, sizeof(buf), fmt, cpy);
     va_end (cpy);
 
+    if (len < 0)
+        return len;
+
     if (len < (int)sizeof(buf)) {
         *dat = util_strdup(buf);
         return len;