zrle: Replace an assert with return -1

pull/30/head
Andri Yngvason 2020-04-10 12:36:51 +00:00
parent a0d49f774a
commit 0350ba1d16
1 changed files with 3 additions and 4 deletions

View File

@ -178,8 +178,6 @@ void zrle_encode_tile(struct vec* dst, const struct rfb_pixel_format* dst_fmt,
int zrle_deflate(struct vec* dst, const struct vec* src, z_stream* zs, bool flush) int zrle_deflate(struct vec* dst, const struct vec* src, z_stream* zs, bool flush)
{ {
int r = Z_STREAM_ERROR;
zs->next_in = src->data; zs->next_in = src->data;
zs->avail_in = src->len; zs->avail_in = src->len;
@ -190,8 +188,9 @@ int zrle_deflate(struct vec* dst, const struct vec* src, z_stream* zs, bool flus
zs->next_out = ((Bytef*)dst->data) + dst->len; zs->next_out = ((Bytef*)dst->data) + dst->len;
zs->avail_out = dst->cap - dst->len; zs->avail_out = dst->cap - dst->len;
r = deflate(zs, flush ? Z_SYNC_FLUSH : Z_NO_FLUSH); int r = deflate(zs, flush ? Z_SYNC_FLUSH : Z_NO_FLUSH);
assert(r != Z_STREAM_ERROR); if (r == Z_STREAM_ERROR)
return -1;
dst->len = zs->next_out - (Bytef*)dst->data; dst->len = zs->next_out - (Bytef*)dst->data;
} while (zs->avail_out == 0); } while (zs->avail_out == 0);