mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
Avoid panic when streaming packets are empty (#1861)
* changed [] access to .get() to return result instead of panic * changed error type to protocol err * fixed issue with comparing ref * cargo fmt Co-authored-by: Erik Rhodes <erik@space-nav.com>
This commit is contained in:
parent
63291d677f
commit
c744cb7f60
1 changed files with 5 additions and 1 deletions
|
@ -148,7 +148,11 @@ impl MySqlStream {
|
|||
// TODO: packet compression
|
||||
// TODO: packet joining
|
||||
|
||||
if payload[0] == 0xff {
|
||||
if payload
|
||||
.get(0)
|
||||
.ok_or(err_protocol!("Packet empty"))?
|
||||
.eq(&0xff)
|
||||
{
|
||||
self.waiting.pop_front();
|
||||
|
||||
// instead of letting this packet be looked at everywhere, we check here
|
||||
|
|
Loading…
Reference in a new issue