summaryrefslogtreecommitdiff
path: root/stun
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-01-14 13:57:37 +0000
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-01-31 01:48:57 -0500
commit649d886143a31caf1d858f8c25a0703e57de74d4 (patch)
treeaec30cdceadfbf7db1070122c95edace5cf150f4 /stun
parentc796e9d8c86af7a4a2c1ab36d4809e5070644272 (diff)
downloadlibnice-649d886143a31caf1d858f8c25a0703e57de74d4.tar.gz
stun: Fix potential zero-length memset() call
GCC warns about this. Might as well prevent the warning.
Diffstat (limited to 'stun')
-rw-r--r--stun/stunmessage.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/stun/stunmessage.c b/stun/stunmessage.c
index b9c54e3..3e55368 100644
--- a/stun/stunmessage.c
+++ b/stun/stunmessage.c
@@ -357,9 +357,11 @@ stun_message_append (StunMessage *msg, StunAttribute type, size_t length)
* to a multiple of 4 for compatibility with old RFC3489 */
a = stun_setw (a, stun_message_has_cookie (msg) ? length : stun_align (length));
- /* Add padding if needed */
- memset (a + length, ' ', stun_padding (length));
- mlen += stun_padding (length);
+ /* Add padding if needed. Avoid a zero-length memset() call. */
+ if (stun_padding (length) > 0) {
+ memset (a + length, ' ', stun_padding (length));
+ mlen += stun_padding (length);
+ }
}
mlen += 4 + length;