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:10:37 +0000 (10:10 +1000)
commit74ef4b8fb9c78f517c97c51a91af4bacba785ed6
tree432c2e8ef945258d2e386ba8caed1ca8c0216f57
parent738a9dd53cacce593cd7d67e18e1273549640a79
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)

(cherry picked from commit 0a3452520fe4cd6871ae8b7c4199c6d5d4efe912)
apps/apps.c