add some missing realloc checks
Change-Id: I0fd1e094085c18b1d9a32333e876c2affeb6de23
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user