- s.temp_dwt_buffer = av_mallocz(width * sizeof(DWTELEM));
- s.temp_idwt_buffer = av_mallocz(width * sizeof(IDWTELEM));
+ s.temp_dwt_buffer = av_mallocz_array(width, sizeof(DWTELEM));
+ s.temp_idwt_buffer = av_mallocz_array(width, sizeof(IDWTELEM));
+
+ if (!s.temp_dwt_buffer || !s.temp_idwt_buffer) {
+ fprintf(stderr, "Failed to allocate memory\n");
+ return 1;
+ }