Skip to content

Commit 6abcdef

Browse files
committed
Fix potential leaks when writing to BIO fails
When the BIO is created but writing fails, these can leak.
1 parent a162004 commit 6abcdef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/openssl/openssl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5742,8 +5742,8 @@ PHP_FUNCTION(openssl_pkcs7_read)
57425742
BIO_get_mem_ptr(bio_out, &bio_buf);
57435743
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
57445744
add_index_zval(zout, i, &zcert);
5745-
BIO_free(bio_out);
57465745
}
5746+
BIO_free(bio_out);
57475747
}
57485748
}
57495749

@@ -5757,8 +5757,8 @@ PHP_FUNCTION(openssl_pkcs7_read)
57575757
BIO_get_mem_ptr(bio_out, &bio_buf);
57585758
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
57595759
add_index_zval(zout, i, &zcert);
5760-
BIO_free(bio_out);
57615760
}
5761+
BIO_free(bio_out);
57625762
}
57635763
}
57645764

@@ -6383,8 +6383,8 @@ PHP_FUNCTION(openssl_cms_read)
63836383
BIO_get_mem_ptr(bio_out, &bio_buf);
63846384
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
63856385
add_index_zval(zout, i, &zcert);
6386-
BIO_free(bio_out);
63876386
}
6387+
BIO_free(bio_out);
63886388
}
63896389
}
63906390

@@ -6398,8 +6398,8 @@ PHP_FUNCTION(openssl_cms_read)
63986398
BIO_get_mem_ptr(bio_out, &bio_buf);
63996399
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
64006400
add_index_zval(zout, i, &zcert);
6401-
BIO_free(bio_out);
64026401
}
6402+
BIO_free(bio_out);
64036403
}
64046404
}
64056405

0 commit comments

Comments
 (0)