From 9cea2dfb8fc65868d054a87041feb6f778918fc3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 2 Oct 2008 14:44:18 +0000 Subject: fix compiler warning: dereferencing type-punned pointer will break strict-aliasing rules --- tests/server/getpart.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'tests/server') diff --git a/tests/server/getpart.c b/tests/server/getpart.c index d32f480d2..1a2a3ca12 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -61,14 +61,20 @@ char *appendstring(char *string, /* original string */ size_t *stralloc, /* allocated size */ char base64) /* 1 if base64 encoded */ { + union { + unsigned char * as_uchar; + char * as_char; + } buf64; + size_t len = strlen(buffer); size_t needed_len = len + *stringlen + 1; - char *buf64=NULL; + + buf64.as_char = NULL; if(base64) { /* decode the given buffer first */ - len = Curl_base64_decode(buffer, (unsigned char**)&buf64); /* updated len */ - buffer = buf64; + len = Curl_base64_decode(buffer, &buf64.as_uchar); /* updated len */ + buffer = buf64.as_char; needed_len = len + *stringlen + 1; /* recalculate */ } @@ -82,8 +88,8 @@ char *appendstring(char *string, /* original string */ *stralloc = newsize; } else { - if(buf64) - free(buf64); + if(buf64.as_char) + free(buf64.as_char); return NULL; } } @@ -92,8 +98,8 @@ char *appendstring(char *string, /* original string */ *stringlen += len; string[*stringlen]=0; - if(buf64) - free(buf64); + if(buf64.as_char) + free(buf64.as_char); return string; } -- cgit v1.2.3