Check return type for vasprintf in libocpf.
authorBrad Hards <bradh@openchange.org>
Sun, 6 Jun 2010 10:33:12 +0000 (10:33 +0000)
committerBrad Hards <bradh@openchange.org>
Sun, 6 Jun 2010 10:33:12 +0000 (10:33 +0000)
libocpf/ocpf_api.c
libocpf/ocpf_dump.c

index 3898e7ca82da9d14579f16f9731617cb06b28775..ecc28f4b75e343667bafdd2c31b6671533d2eb27 100644 (file)
@@ -42,6 +42,11 @@ void ocpf_do_debug(struct ocpf_context *ctx, const char *format, ...)
        ret = vasprintf(&s, format, ap);
        va_end(ap);
 
+       if (ret == -1) {
+               printf("%s:%d: [Debug dump failure]\n", ctx->filename, ctx->lineno);
+               fflush(0);
+               return;
+       }
        if (ctx) {
                printf("%s:%d: %s\n", ctx->filename, ctx->lineno, s);
                fflush(0);
index a5c876e276971d9855e5329014b66f37bd05e010..ec63820a0df2f056ba277729a8e5505dda9f5e4e 100644 (file)
@@ -38,7 +38,11 @@ static void ocpf_do_dump(const char *format, ...)
        ret = vasprintf(&s, format, ap);
        va_end(ap);
 
-       printf("%s\n", s);
+       if (ret == -1) {
+               printf("[Dump failure]\n");
+       } else {
+               printf("%s\n", s);
+       }
        free(s);
 }