* srec.c (srec_get_section_contents): Return immediately on
[deliverable/binutils-gdb.git] / bfd / srec.c
index a5f588c231e99c811e3f5d8990900f5218745541..ebb039bba36eb635cdc315d70d6ba49418b4e075 100644 (file)
@@ -781,10 +781,20 @@ srec_get_section_contents (bfd *abfd,
                           file_ptr offset,
                           bfd_size_type count)
 {
+  if (count == 0)
+    return TRUE;
+
+  if (offset + count < count
+      || offset + count > section->size)
+    {
+      bfd_set_error (bfd_error_invalid_operation);
+      return FALSE;
+    }
+
   if (section->used_by_bfd == NULL)
     {
       section->used_by_bfd = bfd_alloc (abfd, section->size);
-      if (section->used_by_bfd == NULL && section->size != 0)
+      if (section->used_by_bfd == NULL)
        return FALSE;
 
       if (! srec_read_section (abfd, section, section->used_by_bfd))
This page took 0.025396 seconds and 4 git commands to generate.