aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2013-03-03 19:48:20 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-07-13 14:24:57 +0200
commitfadbe80c4389185f80b3d5a8814510f957a6ca8a (patch)
treeadd26398f8c39390f790386622062ca23123476d
parent7fef6e817eab44d849846853e8efb0b547c4ad1f (diff)
downloadlibssh-fadbe80c4389185f80b3d5a8814510f957a6ca8a.tar.gz
libssh-fadbe80c4389185f80b3d5a8814510f957a6ca8a.tar.xz
libssh-fadbe80c4389185f80b3d5a8814510f957a6ca8a.zip
options: Fix null ptr deference introduced in earlier fix.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/options.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c
index d389f7c9..464e806a 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1017,6 +1017,13 @@ int ssh_options_getopt(ssh_session session, int *argcptr, char **argv) {
} /* switch */
} /* while */
opterr = saveopterr;
+ tmp = realloc(save, (current + (argc - optind)) * sizeof(char*));
+ if (tmp == NULL) {
+ SAFE_FREE(save);
+ ssh_set_error_oom(session);
+ return -1;
+ }
+ save = tmp;
while (optind < argc) {
tmp = realloc(save, (current + 1) * sizeof(char*));
if (tmp == NULL) {