This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] bfd, compress.c (bfd_compress_section_contents): Check for out of mem.


Fail gracefully if not enough memory for operation.

OK?

2011-03-05  Michael Snyder  <msnyder@vmware.com>

	* compress.c (bfd_compress_section_contents): Check for out of mem.

Index: compress.c
===================================================================
RCS file: /cvs/src/src/bfd/compress.c,v
retrieving revision 1.7
diff -u -p -r1.7 compress.c
--- compress.c	24 Dec 2010 10:40:19 -0000	1.7
+++ compress.c	6 Mar 2011 00:32:01 -0000
@@ -100,6 +100,12 @@ bfd_compress_section_contents (bfd *abfd
   compressed_size = compressBound (uncompressed_size) + 12;
   compressed_buffer = (bfd_byte *) bfd_malloc (compressed_size);
 
+  if (compressed_buffer == NULL)
+    {
+      bfd_set_error (bfd_error_no_memory);
+      return FALSE;
+    }
+
   if (compress ((Bytef*) compressed_buffer + 12,
 		&compressed_size,
 		(const Bytef*) uncompressed_buffer,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]