Avoid 'NULL + 1' as it is UB

This commit is contained in:
Tim Rühsen 2022-01-16 12:55:51 +01:00
parent 55d0ae04de
commit 21d2d51911
1 changed files with 4 additions and 2 deletions

View File

@ -568,7 +568,7 @@ static int domain_to_punycode(const char *domain, char *out, size_t outsize)
punycode_uint input[256];
const char *label, *e;
for (e = label = domain; e; label = e + 1) {
for (e = label = domain; e;) {
e = strchr(label, '.');
labellen = e ? (size_t) (e - label) : strlen(label);
@ -596,8 +596,10 @@ static int domain_to_punycode(const char *domain, char *out, size_t outsize)
outlen += labellen;
}
if (e)
if (e) {
label = e + 1;
out[outlen++] = '.';
}
out[outlen] = 0;
}