raw-encoding: Fix vec_reserve for destination buffer

tight-png
Andri Yngvason 2019-09-21 13:33:37 +00:00
parent 4c36a88cfd
commit 0f840b9bb7
1 changed files with 4 additions and 4 deletions

View File

@ -19,10 +19,6 @@ int raw_encode_box(struct vec *dst, const struct rfb_pixel_format *dst_fmt,
.height = htons(height), .height = htons(height),
}; };
rc = vec_reserve(dst, width * height * 4 + 256);
if (rc < 0)
return -1;
rc = vec_append(dst, &rect, sizeof(rect)); rc = vec_append(dst, &rect, sizeof(rect));
if (rc < 0) if (rc < 0)
return -1; return -1;
@ -62,6 +58,10 @@ int raw_encode_frame(struct vec *dst,
.n_rects = htons(n_rects), .n_rects = htons(n_rects),
}; };
rc = vec_reserve(dst, src->width * src->height * 4 + 256);
if (rc < 0)
return -1;
rc = vec_append(dst, &head, sizeof(head)); rc = vec_append(dst, &head, sizeof(head));
if (rc < 0) if (rc < 0)
return -1; return -1;