diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1998-08-16 20:54:50 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1998-08-16 20:54:50 +0000 |
commit | 976c506be0a96c2303d0f33a3a62aabcf564690c (patch) | |
tree | 0c12fad8457172d5404f6f0b9d2f089944da9864 /kerberosIV | |
parent | a7461f865d648909ea4d538af010b582d0218271 (diff) |
realloc misuse
Diffstat (limited to 'kerberosIV')
-rw-r--r-- | kerberosIV/roken/getarg.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kerberosIV/roken/getarg.c b/kerberosIV/roken/getarg.c index 1ca11986444..d5081e5aa0e 100644 --- a/kerberosIV/roken/getarg.c +++ b/kerberosIV/roken/getarg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getarg.c,v 1.2 1998/08/12 23:39:38 art Exp $ */ +/* $OpenBSD: getarg.c,v 1.3 1998/08/16 20:54:49 art Exp $ */ /* $KTH: getarg.c,v 1.18 1998/01/22 20:23:16 joda Exp $ */ /* * Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan @@ -322,7 +322,15 @@ arg_printusage (struct getargs *args, static void add_string(getarg_strings *s, char *value) { - s->strings = realloc(s->strings, (s->num_strings + 1) * sizeof(*s->strings)); + char **temp; + + temp = realloc(s->strings, (s->num_strings + 1) * sizeof(*s->strings)); + if (temp == NULL){ + free (s->strings); + err(1, "realloc:"); + } + s->strings = temp; + s->strings[s->num_strings] = value; s->num_strings++; } |