Fix a buffer overflow in the OSS/BSD backend.

This commit is contained in:
David Reid 2018-03-18 14:37:41 +10:00 committed by GitHub
parent 61e0e4b4f3
commit 4a69c2d75e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6974,7 +6974,7 @@ static mal_result mal_device_init__oss(mal_context* pContext, mal_device_type ty
// When not using MMAP mode, we need to use an intermediary buffer for the client <-> device transfer. We do // When not using MMAP mode, we need to use an intermediary buffer for the client <-> device transfer. We do
// everything by the size of a fragment. // everything by the size of a fragment.
pDevice->oss.pIntermediaryBuffer = mal_malloc(fragmentSizeInBytes); pDevice->oss.pIntermediaryBuffer = mal_malloc(actualFragmentSizeInBytes);
if (pDevice->oss.pIntermediaryBuffer == NULL) { if (pDevice->oss.pIntermediaryBuffer == NULL) {
close(pDevice->oss.fd); close(pDevice->oss.fd);
return mal_post_error(pDevice, "[OSS] Failed to allocate memory for intermediary buffer.", MAL_OUT_OF_MEMORY); return mal_post_error(pDevice, "[OSS] Failed to allocate memory for intermediary buffer.", MAL_OUT_OF_MEMORY);