coverity fix

This commit is contained in:
iceman1001 2020-05-08 21:13:01 +02:00
commit a96e94b872

View file

@ -110,24 +110,27 @@ void initSampleBuffer(uint32_t *sample_size) {
} }
void initSampleBufferEx(uint32_t *sample_size, bool use_malloc) { void initSampleBufferEx(uint32_t *sample_size, bool use_malloc) {
if (sample_size == NULL) {
Dbprintf("initSampleBufferEx, param NULL");
return;
}
BigBuf_free(); BigBuf_free();
// We can't erase the buffer now, it would drastically delay the acquisition // We can't erase the buffer now, it would drastically delay the acquisition
if (use_malloc) { if (use_malloc) {
if (sample_size == NULL || *sample_size == 0) { if (*sample_size == 0) {
*sample_size = BigBuf_max_traceLen(); *sample_size = BigBuf_max_traceLen();
data.buffer = BigBuf_get_addr(); data.buffer = BigBuf_get_addr();
} else { } else {
*sample_size = MIN(*sample_size, BigBuf_max_traceLen()); *sample_size = MIN(*sample_size, BigBuf_max_traceLen());
data.buffer = BigBuf_malloc(*sample_size); data.buffer = BigBuf_malloc(*sample_size);
} }
} else { } else {
if (sample_size == NULL || *sample_size == 0) { if (*sample_size == 0) {
*sample_size = BigBuf_max_traceLen(); *sample_size = BigBuf_max_traceLen();
} }
data.buffer = BigBuf_get_addr(); data.buffer = BigBuf_get_addr();