harness some malloc/calloc to use WebPSafeMalloc and WebPSafeCalloc
quite a large security sweep. Change-Id: If150dfbb46e6e9b56210473a109c8ad6ccd0cea4
This commit is contained in:
		@@ -16,6 +16,7 @@
 | 
			
		||||
 | 
			
		||||
#include "./vp8enci.h"
 | 
			
		||||
#include "./vp8li.h"
 | 
			
		||||
#include "../utils/utils.h"
 | 
			
		||||
 | 
			
		||||
// #define PRINT_MEMORY_INFO
 | 
			
		||||
 | 
			
		||||
@@ -164,13 +165,14 @@ static VP8Encoder* InitVP8Encoder(const WebPConfig* const config,
 | 
			
		||||
      config->autofilter ? sizeof(LFStats) + ALIGN_CST : 0;
 | 
			
		||||
  VP8Encoder* enc;
 | 
			
		||||
  uint8_t* mem;
 | 
			
		||||
  size_t size = sizeof(VP8Encoder) + ALIGN_CST  // main struct
 | 
			
		||||
              + cache_size                      // working caches
 | 
			
		||||
              + info_size                       // modes info
 | 
			
		||||
              + preds_size                      // prediction modes
 | 
			
		||||
              + samples_size                    // top/left samples
 | 
			
		||||
              + nz_size                         // coeff context bits
 | 
			
		||||
              + lf_stats_size;                  // autofilter stats
 | 
			
		||||
  const uint64_t size = (uint64_t)sizeof(VP8Encoder)   // main struct
 | 
			
		||||
                      + ALIGN_CST                      // cache alignment
 | 
			
		||||
                      + cache_size                     // working caches
 | 
			
		||||
                      + info_size                      // modes info
 | 
			
		||||
                      + preds_size                     // prediction modes
 | 
			
		||||
                      + samples_size                   // top/left samples
 | 
			
		||||
                      + nz_size                        // coeff context bits
 | 
			
		||||
                      + lf_stats_size;                 // autofilter stats
 | 
			
		||||
 | 
			
		||||
#ifdef PRINT_MEMORY_INFO
 | 
			
		||||
  printf("===================================\n");
 | 
			
		||||
@@ -198,7 +200,7 @@ static VP8Encoder* InitVP8Encoder(const WebPConfig* const config,
 | 
			
		||||
         mb_w * mb_h * 384 * sizeof(uint8_t));
 | 
			
		||||
  printf("===================================\n");
 | 
			
		||||
#endif
 | 
			
		||||
  mem = (uint8_t*)malloc(size);
 | 
			
		||||
  mem = (uint8_t*)WebPSafeMalloc(size, sizeof(*mem));
 | 
			
		||||
  if (mem == NULL) {
 | 
			
		||||
    WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
 | 
			
		||||
    return NULL;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user