Fix dynamic SCSI buffer window sizing causing SEGV

This commit is contained in:
A. Wilcox
2025-09-06 02:53:30 -05:00
parent bb95ffaf5f
commit 65c7dfb2ee
2 changed files with 9 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ typedef struct scsi_disk_t {
void * log;
uint8_t * temp_buffer;
size_t temp_buffer_sz;
uint8_t atapi_cdb[16];
uint8_t current_cdb[16];
uint8_t sense[256];

View File

@@ -623,8 +623,15 @@ static void
scsi_disk_buf_alloc(scsi_disk_t *dev, uint32_t len)
{
scsi_disk_log(dev->log, "Allocated buffer length: %i\n", len);
if (dev->temp_buffer == NULL)
if (dev->temp_buffer == NULL) {
dev->temp_buffer = (uint8_t *) malloc(len);
dev->temp_buffer_sz = len;
}
if (len > dev->temp_buffer_sz) {
uint8_t *buf = (uint8_t *) realloc(dev->temp_buffer, len);
dev->temp_buffer = buf;
dev->temp_buffer_sz = len;
}
}
static void