[PATCH] http: Check asprintf() return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux