[PATCH] http: Check asprintf() return value

Kevin Cernekee cernekee at gmail.com
Wed Jun 18 08:40:57 PDT 2014


This fixes the following warning:

      CC       libopenconnect_la-http.lo
    http.c: In function 'openconnect_obtain_cookie':
    http.c:1270:13: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]
         asprintf(&vpninfo->profile_url, "%s%s", bu, fu);
                 ^

Signed-off-by: Kevin Cernekee <cernekee at gmail.com>
---
 http.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/http.c b/http.c
index 90ac060..6fec357 100644
--- a/http.c
+++ b/http.c
@@ -1267,7 +1267,10 @@ newgroup:
 			} while ((tok = strchr(tok, '&')));
 
 			if (bu && fu && sha) {
-				asprintf(&vpninfo->profile_url, "%s%s", bu, fu);
+				if (asprintf(&vpninfo->profile_url, "%s%s", bu, fu) == -1) {
+					result = -ENOMEM;
+					goto out;
+				}
 				vpninfo->profile_sha1 = strdup(sha);
 			}
 		}
-- 
1.7.9.5




More information about the openconnect-devel mailing list