summaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authormifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-01-23 19:28:10 +0000
committermifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-01-23 19:28:10 +0000
commit651ba91465d05f64b7650334499e320f6851936c (patch)
tree9020a659f8a944375b1fa8a92a2eeef490417789 /src/target
parent06f33996e87f6fddb241b2d6ebde552619440adc (diff)
downloadopenocd+libswd-651ba91465d05f64b7650334499e320f6851936c.tar.gz
openocd+libswd-651ba91465d05f64b7650334499e320f6851936c.tar.bz2
openocd+libswd-651ba91465d05f64b7650334499e320f6851936c.tar.xz
openocd+libswd-651ba91465d05f64b7650334499e320f6851936c.zip
- added patch to fix crash in load_image on corrupt elf file or out of memory.
(thanks to Øyvind Harboe for the patch) git-svn-id: svn://svn.berlios.de/openocd/trunk@274 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r--src/target/target.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/target/target.c b/src/target/target.c
index fc821f8f..f77de339 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);