This is probably fatal anyway, but it is better to fail in a predictable manner. Signed-off-by: Kevin Cernekee <cernekee at gmail.com> --- library.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library.c b/library.c index c0ec763..726e4dd 100644 --- a/library.c +++ b/library.c @@ -50,6 +50,9 @@ struct openconnect_info *openconnect_vpninfo_new(char *useragent, { struct openconnect_info *vpninfo = calloc(sizeof(*vpninfo), 1); + if (!vpninfo) + return NULL; + vpninfo->tun_fd = vpninfo->ssl_fd = vpninfo->dtls_fd = vpninfo->new_dtls_fd = -1; vpninfo->cancel_fd = vpninfo->cancel_fd_write = -1; vpninfo->cert_expire_warning = 60 * 86400; @@ -68,6 +71,13 @@ struct openconnect_info *openconnect_vpninfo_new(char *useragent, vpninfo->xmlpost = 1; openconnect_set_reported_os(vpninfo, NULL); + if (!vpninfo->localname || !vpninfo->useragent) { + free(vpninfo->localname); + free(vpninfo->useragent); + free(vpninfo); + return NULL; + } + #ifdef ENABLE_NLS bindtextdomain("openconnect", LOCALEDIR); #endif -- 1.7.9.5