Import warning fixes from Samba 3.
[ira/wip.git] / source4 / librpc / ndr / ndr.c
index e19a1eb9badf5ff530fe97e557d9f1c1a902fdbc..e8daa99e15bc60d864b7a7569b25e7586981458d 100644 (file)
@@ -163,16 +163,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_
        return NDR_ERR_SUCCESS;
 }
 
-_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...)
+_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) 
 {
        va_list ap;
        char *s = NULL;
-       int i;
+       int i, ret;
 
        va_start(ap, format);
-       vasprintf(&s, format, ap);
+       ret = vasprintf(&s, format, ap);
        va_end(ap);
 
+       if (ret == -1) {
+               return;
+       }
+
        for (i=0;i<ndr->depth;i++) {
                DEBUGADD(0,("    "));
        }
@@ -350,12 +354,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
 {
        char *s=NULL;
        va_list ap;
+       int ret;
 
        va_start(ap, format);
-       vasprintf(&s, format, ap);
+       ret = vasprintf(&s, format, ap);
        va_end(ap);
 
-       DEBUG(3,("ndr_pull_error(%u): %s\n", ndr_err, s));
+       if (ret == -1) {
+               return NDR_ERR_ALLOC;
+       }
+
+       DEBUG(1,("ndr_pull_error(%u): %s\n", ndr_err, s));
 
        free(s);
 
@@ -367,16 +376,21 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
 */
 _PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr,
                                 enum ndr_err_code ndr_err,
-                                const char *format, ...)
+                                const char *format, ...) 
 {
        char *s=NULL;
        va_list ap;
+       int ret;
 
        va_start(ap, format);
-       vasprintf(&s, format, ap);
+       ret = vasprintf(&s, format, ap);
        va_end(ap);
 
-       DEBUG(3,("ndr_push_error(%u): %s\n", ndr_err, s));
+       if (ret == -1) {
+               return NDR_ERR_ALLOC;
+       }
+
+       DEBUG(1,("ndr_push_error(%u): %s\n", ndr_err, s));
 
        free(s);