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