summaryrefslogtreecommitdiff
path: root/methods/rred.cc
diff options
context:
space:
mode:
Diffstat (limited to 'methods/rred.cc')
-rw-r--r--methods/rred.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/methods/rred.cc b/methods/rred.cc
index e37a12ed9..1e352d0e7 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -333,7 +333,12 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
}
if(command_count == command_alloc) {
command_alloc = (command_alloc + 64) * 3 / 2;
- commands = (EdCommand*) realloc(commands, command_alloc * sizeof(EdCommand));
+ EdCommand* newCommands = (EdCommand*) realloc(commands, command_alloc * sizeof(EdCommand));
+ if (newCommands == NULL) {
+ free(commands);
+ return MMAP_FAILED;
+ }
+ commands = newCommands;
}
commands[command_count++] = cmd;
}