_bfd_mul_overflow
[deliverable/binutils-gdb.git] / bfd / wasm-module.c
index dfd3d873b22435a7077af69be448dcf04ebede3f..315d3effb8db4dd554440cd396c224216a2a2c75 100644 (file)
@@ -245,6 +245,7 @@ wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
   tdata_type *tdata = abfd->tdata.any;
   asymbol *symbols = NULL;
   sec_ptr space_function_index;
+  size_t amt;
 
   p = asect->contents;
   end = asect->contents + asect->size;
@@ -301,7 +302,12 @@ wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
   if (!space_function_index)
     return FALSE;
 
-  symbols = bfd_alloc2 (abfd, tdata->symcount, sizeof (asymbol));
+  if (_bfd_mul_overflow (tdata->symcount, sizeof (asymbol), &amt))
+    {
+      bfd_set_error (bfd_error_file_too_big);
+      return FALSE;
+    }
+  symbols = bfd_alloc (abfd, amt);
   if (!symbols)
     return FALSE;
 
This page took 0.024313 seconds and 4 git commands to generate.