mirror of
https://github.com/tmux/tmux.git
synced 2026-10-10 12:14:43 +00:00
Do not allocate when a Kitty payload chunk decodes to no bytes.
This commit is contained in:
@@ -952,6 +952,12 @@ kitty_append(struct kitty_state *ks, const u_char *buf, size_t len)
|
||||
free(copy);
|
||||
if (decoded == NULL)
|
||||
return (-1);
|
||||
|
||||
/* Empty decoded chunks need no allocation. */
|
||||
if (decodedlen == 0) {
|
||||
free(decoded);
|
||||
return (0);
|
||||
}
|
||||
if (decodedlen > IMAGE_SIZE_LIMIT - ks->rawlen) {
|
||||
free(decoded);
|
||||
return (-1);
|
||||
|
||||
@@ -142,6 +142,12 @@ with tempfile.TemporaryDirectory(prefix='tmux-kitty-protocol-') as tmp:
|
||||
check('invalid-reply', origin + graphics('a=T,i=7,p=9,f=32,s=1,v=1', '!!!!'),
|
||||
'5,2', graphics('i=7,p=9', 'EINVAL'))
|
||||
check('quiet-error', origin + graphics('a=T,q=2,i=7,f=32,s=1,v=1', '!!!!'), '5,2')
|
||||
check('empty-decoded-payload', origin +
|
||||
graphics('a=T,i=7,f=32,s=1,v=1', ' '), '5,2',
|
||||
graphics('i=7', 'EINVAL'))
|
||||
check('empty-decoded-chunk',
|
||||
graphics(placement + ',m=1', ' ') + origin +
|
||||
graphics('m=0', pixel), '8,4')
|
||||
check('quiet-ok', origin + graphics('a=t,q=1,i=7,f=32,s=1,v=1', pixel), '5,2')
|
||||
check('quiet-one-error', origin + graphics('a=t,q=1,i=7,f=32,s=1,v=1', '!!!!'),
|
||||
'5,2', graphics('i=7', 'EINVAL'))
|
||||
|
||||
Reference in New Issue
Block a user