
< 		gsm->buf[gsm->count++] = c;
< 		if (gsm->count == gsm->len)
---
> 		if (gsm->count >= sizeof(gsm->buf)) {
> 			gsm->state = GSM_RECOVERY;  // Or appropriate error handling
> 			return;
> 		}
> 		gsm->buf[gsm->count++] = c;
> 		if (gsm->count == gsm->len)
