Skip to content

Commit 18164e6

Browse files
authored
Fixes crash when calling twice end() (espressif#8332)
1 parent 72c41d0 commit 18164e6

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Diff for: cores/esp32/HWCDC.cpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ void HWCDC::setTxTimeoutMs(uint32_t timeout){
218218

219219
size_t HWCDC::setTxBufferSize(size_t tx_queue_len){
220220
if(tx_ring_buf){
221-
if(!tx_queue_len){
222-
vRingbufferDelete(tx_ring_buf);
223-
tx_ring_buf = NULL;
224-
}
221+
vRingbufferDelete(tx_ring_buf);
222+
tx_ring_buf = NULL;
223+
}
224+
if(!tx_queue_len){
225225
return 0;
226226
}
227227
tx_ring_buf = xRingbufferCreate(tx_queue_len, RINGBUF_TYPE_BYTEBUF);
@@ -319,19 +319,16 @@ void HWCDC::flush(void)
319319

320320
size_t HWCDC::setRxBufferSize(size_t rx_queue_len){
321321
if(rx_queue){
322-
if(!rx_queue_len){
323-
vQueueDelete(rx_queue);
324-
rx_queue = NULL;
325-
}
322+
vQueueDelete(rx_queue);
323+
rx_queue = NULL;
324+
}
325+
if(!rx_queue_len){
326326
return 0;
327327
}
328328
rx_queue = xQueueCreate(rx_queue_len, sizeof(uint8_t));
329329
if(!rx_queue){
330330
return 0;
331331
}
332-
if(!tx_ring_buf){
333-
tx_ring_buf = xRingbufferCreate(rx_queue_len, RINGBUF_TYPE_BYTEBUF);
334-
}
335332
return rx_queue_len;
336333
}
337334

0 commit comments

Comments
 (0)