From 87ca206e13ab4245280e0208b46b7b4b6682d2c9 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 10 Jun 2007 18:08:22 +0000 Subject: Warning fixes. svn path=/trunk/netsurf/; revision=3332 --- utils/useragent.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'utils') diff --git a/utils/useragent.c b/utils/useragent.c index b76255f2c..085557d7e 100644 --- a/utils/useragent.c +++ b/utils/useragent.c @@ -8,10 +8,11 @@ #include #include +#include -#include "useragent.h" #include "desktop/netsurf.h" #include "utils/log.h" +#include "utils/useragent.h" static const char *core_user_agent_string = NULL; @@ -27,25 +28,32 @@ build_user_agent(void) struct utsname un; const char *sysname = "Unknown"; const char *machine = "Unknown"; + char *ua_string; int len; - + if (uname(&un) == 0) { sysname = un.sysname; machine = un.machine; } - + len = snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING, netsurf_version_major, netsurf_version_minor, - un.sysname, - un.machine); - core_user_agent_string = malloc(len + 1); - snprintf(core_user_agent_string, len + 1, + sysname, + machine); + ua_string = malloc(len + 1); + if (!ua_string) { + /** \todo this needs handling better */ + return; + } + snprintf(ua_string, len + 1, NETSURF_UA_FORMAT_STRING, netsurf_version_major, netsurf_version_minor, - un.sysname, - un.machine); + sysname, + machine); + + core_user_agent_string = ua_string; LOG(("Built user agent \"%s\"", core_user_agent_string)); } -- cgit v1.2.3