diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-02-04 20:35:52 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-02-04 20:35:52 +0000 |
commit | 0a590d1c07dbb852b481db08aa55ce673d3725f4 (patch) | |
tree | 5d8dcdb04e6a5f28180c09868c7cc40272859747 /lib | |
parent | 1410e8e594f17dc6735bea138bffa505d5583bf5 (diff) |
Replace realloc() with reallocarray() in libkeynote. Do not free
keynote_lex_list after it has been reallocated.
Found by Benjamin Baier with llvm/scan-build; OK florian@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libkeynote/keynote.l | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/libkeynote/keynote.l b/lib/libkeynote/keynote.l index b3f0ffd4f16..02d10b039f5 100644 --- a/lib/libkeynote/keynote.l +++ b/lib/libkeynote/keynote.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: keynote.l,v 1.20 2013/11/29 19:00:51 deraadt Exp $ */ +/* $OpenBSD: keynote.l,v 1.21 2015/02/04 20:35:51 bluhm Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu) * @@ -269,9 +269,9 @@ keynote_lex_add(void *s, int type) /* Not enough space, increase the size of the array */ keynote_max_lex_list *= 2; - p = (struct lex_list *) realloc(keynote_lex_list, - keynote_max_lex_list * - sizeof(struct lex_list)); + p = (struct lex_list *) reallocarray(keynote_lex_list, + keynote_max_lex_list, + sizeof(struct lex_list)); if (p == (struct lex_list *) NULL) { switch (type) @@ -286,9 +286,6 @@ keynote_lex_add(void *s, int type) return -1; } - if (p != keynote_lex_list) - free(keynote_lex_list); - keynote_lex_list = p; keynote_lex_list[i].lex_s = s; keynote_lex_list[i++].lex_type = type; |