From: Alan T. DeKok Date: Tue, 31 Mar 2020 13:46:30 +0000 (-0400) Subject: we should pretty much NEVER use "*++p". Instead, use *(p++) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5c4a76cbff36731d04edcc8dfe1a6d4ecdfbdf6;p=thirdparty%2Ffreeradius-server.git we should pretty much NEVER use "*++p". Instead, use *(p++) The first one increments 'p' BEFORE assigning. Which results in uninitialized memory. The second on increments 'p' AFTER assigning. Which is what we want --- diff --git a/src/protocols/internal/encode.c b/src/protocols/internal/encode.c index f733ece8605..f9a68d11f39 100644 --- a/src/protocols/internal/encode.c +++ b/src/protocols/internal/encode.c @@ -55,7 +55,7 @@ static ssize_t internal_encode(uint8_t *out, size_t outlen, /* * Zero out 'enc_field' */ - *++p = 0x00; + *(p++) = 0x00; /* * Ensure we have at least enough space @@ -81,7 +81,7 @@ static ssize_t internal_encode(uint8_t *out, size_t outlen, * Need to use the second encoding byte */ if (da->flags.is_unknown) { - *++p = 0x00; + *(p++) = 0x00; FR_PAIR_ENCODE_HAVE_SPACE(p, end, (sizeof(uint64_t) * 2) + 2); /* Check we still have room */ enc_field[0] |= FR_INTERNAL_FLAG_EXTENDED;