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

cores/esp32/HWCDC.cpp

Lines changed: 8 additions & 11 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy