mirror of
https://github.com/GNOME/libxml2.git
synced 2025-10-20 22:30:16 +08:00
Fix undefined behavior in UTF16LEToUTF8
Don't perform arithmetic on null pointer. Found with libFuzzer and UBSan.
This commit is contained in:
@@ -496,13 +496,18 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
|
|||||||
{
|
{
|
||||||
unsigned char* outstart = out;
|
unsigned char* outstart = out;
|
||||||
const unsigned char* processed = inb;
|
const unsigned char* processed = inb;
|
||||||
unsigned char* outend = out + *outlen;
|
unsigned char* outend;
|
||||||
unsigned short* in = (unsigned short*) inb;
|
unsigned short* in = (unsigned short*) inb;
|
||||||
unsigned short* inend;
|
unsigned short* inend;
|
||||||
unsigned int c, d, inlen;
|
unsigned int c, d, inlen;
|
||||||
unsigned char *tmp;
|
unsigned char *tmp;
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
|
if (*outlen == 0) {
|
||||||
|
*inlenb = 0;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
outend = out + *outlen;
|
||||||
if ((*inlenb % 2) == 1)
|
if ((*inlenb % 2) == 1)
|
||||||
(*inlenb)--;
|
(*inlenb)--;
|
||||||
inlen = *inlenb / 2;
|
inlen = *inlenb / 2;
|
||||||
|
Reference in New Issue
Block a user