Fix potential use-after-free and memory leak
authorPauli <paul.dale@oracle.com>
Wed, 26 Jul 2017 00:04:05 +0000 (10:04 +1000)
committerPauli <paul.dale@oracle.com>
Wed, 26 Jul 2017 00:04:05 +0000 (10:04 +1000)
commit0a3452520fe4cd6871ae8b7c4199c6d5d4efe912
treec7d265c8420c1125f91e7c4f9fc6ebed38e6a0fe
parente4adad92b3bd161680da874c19342b292ebe4bea
Fix potential use-after-free and memory leak

In function wait_for_async(), allocated async fds is freed if
`SSL_get_all_async_fds` fails, but later `fds` is used. Interestingly,
it is not freed when everything succeeds.

Rewrite the FD set loop to make it more readable and to not modify the allocated
pointer so it can be freed.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/3992)
apps/apps.c