diff options
author | 2015-02-04 20:35:51 +0000 | |
---|---|---|
committer | 2015-02-04 20:35:51 +0000 | |
commit | 862a1c7f6fa25564fbc549b85abeffec6e972612 (patch) | |
tree | f112b1fc5e26dbed161279c2741dc7d879313711 | |
parent | Fix potentional double free in do-while-loop. (diff) | |
download | wireguard-openbsd-862a1c7f6fa25564fbc549b85abeffec6e972612.tar.xz wireguard-openbsd-862a1c7f6fa25564fbc549b85abeffec6e972612.zip |
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@
-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; |