add some missing realloc checks

Change-Id: I0fd1e094085c18b1d9a32333e876c2affeb6de23
This commit is contained in:
James Zern
2022-05-06 11:55:56 -07:00
parent f3b4c9a8f6
commit cb1abee145
3 changed files with 6 additions and 0 deletions

View File

@@ -84,6 +84,7 @@ static int get_frame_stats(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
const uint8_t *const pkt_buf = pkt->data.twopass_stats.buf;
const size_t pkt_size = pkt->data.twopass_stats.sz;
stats->buf = realloc(stats->buf, stats->sz + pkt_size);
if (!stats->buf) die("Failed to reallocate stats buffer.");
memcpy((uint8_t *)stats->buf + stats->sz, pkt_buf, pkt_size);
stats->sz += pkt_size;
}

View File

@@ -98,6 +98,7 @@ class VPxFirstPassEncoderThreadTest
firstpass_stats_.buf =
realloc(firstpass_stats_.buf, firstpass_stats_.sz + pkt_size);
ASSERT_NE(firstpass_stats_.buf, nullptr);
memcpy((uint8_t *)firstpass_stats_.buf + firstpass_stats_.sz, pkt_buf,
pkt_size);
firstpass_stats_.sz += pkt_size;

View File

@@ -453,6 +453,10 @@ int main(int argc, char *argv[]) {
psnry = realloc(psnry, allocated_frames * sizeof(*psnry));
psnru = realloc(psnru, allocated_frames * sizeof(*psnru));
psnrv = realloc(psnrv, allocated_frames * sizeof(*psnrv));
if (!(ssimy && ssimu && ssimv && psnry && psnru && psnrv)) {
fprintf(stderr, "Error allocating SSIM/PSNR data.\n");
exit(EXIT_FAILURE);
}
}
psnr_and_ssim(ssimy[n_frames], psnry[n_frames], y[0], y[1], w, h);
psnr_and_ssim(ssimu[n_frames], psnru[n_frames], u[0], u[1], (w + 1) / 2,