Merge pull request #4992 from JacobBarthelmeh/Compatibility-Layer

support creating new mem bio of length 0
This commit is contained in:
David Garske
2022-03-30 06:55:53 -07:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@ -2537,7 +2537,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio)
len = (int)XSTRLEN((const char*)buf) + 1;
}
if (wolfSSL_BUF_MEM_resize(bio->mem_buf, len) == 0) {
if (len > 0 && wolfSSL_BUF_MEM_resize(bio->mem_buf, len) == 0) {
wolfSSL_BIO_free(bio);
return NULL;
}

View File

@ -39123,6 +39123,9 @@ static void test_wolfSSL_BIO_write(void)
BIO_set_retry_read(bio);
BIO_free_all(bio); /* frees bio64s also */
AssertNotNull(bio = BIO_new_mem_buf(out, 0));
AssertIntEQ(BIO_write(bio, msg, sizeof(msg)), sizeof(msg));
BIO_free(bio);
printf(resultFmt, passed);
#endif
}