mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-13 02:07:53 +00:00
Fix ATMEGA BASH_SERIAL buffer overrun
Changed the compare to TXBUFFER_SIZE to >= If next wasn't set to zero until > TXBUFFER_SIZE then the next time the routines get called the the array index references outside the buffer (e.g tail+1)
This commit is contained in:
parent
4b7e4d6bad
commit
ba4526ee89
@ -975,7 +975,7 @@ void Serial_write( uint8_t byte )
|
||||
byte |= 1 ; // Start bit
|
||||
#endif
|
||||
uint8_t next = SerialControl.head + 2;
|
||||
if(next>TXBUFFER_SIZE)
|
||||
if(next>=TXBUFFER_SIZE)
|
||||
next=0;
|
||||
if ( next != SerialControl.tail )
|
||||
{
|
||||
@ -1069,7 +1069,7 @@ ISR(TIMER0_COMPB_vect)
|
||||
GPIOR0 = ptr->data[ptr->tail] ;
|
||||
GPIOR2 = ptr->data[ptr->tail+1] ;
|
||||
uint8_t nextTail = ptr->tail + 2 ;
|
||||
if ( nextTail > TXBUFFER_SIZE )
|
||||
if ( nextTail >= TXBUFFER_SIZE )
|
||||
nextTail = 0 ;
|
||||
ptr->tail = nextTail ;
|
||||
GPIOR1 = 8 ;
|
||||
@ -1112,7 +1112,7 @@ ISR(TIMER0_OVF_vect)
|
||||
GPIOR0 = ptr->data[ptr->tail] ;
|
||||
GPIOR2 = ptr->data[ptr->tail+1] ;
|
||||
uint8_t nextTail = ptr->tail + 2 ;
|
||||
if ( nextTail > TXBUFFER_SIZE )
|
||||
if ( nextTail >= TXBUFFER_SIZE )
|
||||
nextTail = 0 ;
|
||||
ptr->tail = nextTail ;
|
||||
GPIOR1 = 10 ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user