From 651ba91465d05f64b7650334499e320f6851936c Mon Sep 17 00:00:00 2001 From: mifi Date: Wed, 23 Jan 2008 19:28:10 +0000 Subject: [PATCH] =?utf8?q?-=20added=20patch=20to=20fix=20crash=20in=20load?= =?utf8?q?=5Fimage=20on=20corrupt=20elf=20file=20or=20out=20of=20memory.?= =?utf8?q?=20(thanks=20to=20=C3=98yvind=20Harboe=20for=20the=20patch)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.berlios.de/openocd/trunk@274 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/target.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/target/target.c b/src/target/target.c index fc821f8f14..f77de33939 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -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); -- 2.30.2