]> git.sur5r.net Git - openocd/commitdiff
- added patch to fix crash in load_image on corrupt elf file or out of memory.
authormifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 23 Jan 2008 19:28:10 +0000 (19:28 +0000)
committermifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 23 Jan 2008 19:28:10 +0000 (19:28 +0000)
(thanks to Ã˜yvind Harboe for the patch)

git-svn-id: svn://svn.berlios.de/openocd/trunk@274 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/target/target.c

index fc821f8f14e0b1caa9528d4cac5ea4d63909ccde..f77de33939fa8dd232cf0e452f1fafd813d19261 100644 (file)
@@ -1778,6 +1778,11 @@ int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char
        for (i = 0; i < image.num_sections; i++)
        {
                buffer = malloc(image.sections[i].size);
+               if (buffer==NULL)
+               {
+                       command_print(cmd_ctx, "error allocating buffer for section (%d bytes)", image.sections[i].size);
+                       break;
+               }
                if ((retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt)) != ERROR_OK)
                {
                        ERROR("image_read_section failed with error code: %i", retval);