Certain flag macros were tested with #if instead if #ifdef...
[openssl.git] / crypto / bio / b_print.c
index b7e268f092011b94bc2697ebc3ef9403c4401899..80c9cb69db2bf4e461b7f29af255ffec2e147ebb 100644 (file)
  * [including the GNU Public Licence.]
  */
 
+/* disable assert() unless BIO_DEBUG has been defined */
+#ifndef BIO_DEBUG
+# ifndef NDEBUG
+#  define NDEBUG
+# endif
+#endif
+
 /* 
  * Stolen from tjh's ssl/ssl_trc.c stuff.
  */
  * o ...                                       (for OpenSSL)
  */
 
-#if HAVE_LONG_DOUBLE
+#ifdef HAVE_LONG_DOUBLE
 #define LDOUBLE long double
 #else
 #define LDOUBLE double
@@ -716,12 +723,13 @@ doapr_outch(
     if (buffer) {
        while (*currlen >= *maxlen) {
            if (*buffer == NULL) {
-               assert(*sbuffer != NULL);
                if (*maxlen == 0)
                    *maxlen = 1024;
                *buffer = OPENSSL_malloc(*maxlen);
-               if (*currlen > 0)
+               if (*currlen > 0) {
+                   assert(*sbuffer != NULL);
                    memcpy(*buffer, *sbuffer, *currlen);
+               }
                *sbuffer = NULL;
            } else {
                *maxlen += 1024;
@@ -761,7 +769,9 @@ int BIO_vprintf (BIO *bio, const char *format, va_list args)
        {
        int ret;
        size_t retlen;
-       MS_STATIC char hugebuf[1024*10];
+       char hugebuf[1024*2];   /* Was previously 10k, which is unreasonable
+                                  in small-stack environments, like threads
+                                  or DOS programs. */
        char *hugebufp = hugebuf;
        size_t hugebufsize = sizeof(hugebuf);
        char *dynbuf = NULL;