fix compiler warning: dereferencing type-punned pointer will break strict-aliasing rules

This commit is contained in:
Yang Tse 2008-10-02 14:44:18 +00:00
parent 00dec36c72
commit 9cea2dfb8f
1 changed files with 13 additions and 7 deletions

View File

@ -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;
}