From 57222779f460df0730438535e72a9e20494dbe89 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 19 Nov 2013 13:59:12 -0500 Subject: Remove a possible memmove() of 0 bytes Don't bother memmove()ing a 0-byte chunk of data. Found by static analysis. --- src/disp-nis.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/disp-nis.c b/src/disp-nis.c index 5e0c883..b584765 100644 --- a/src/disp-nis.c +++ b/src/disp-nis.c @@ -770,10 +770,12 @@ client_read(struct plugin_state *state, struct dispatch_client *client) client->client_query = query; client->client_query_size = nlen; /* Drop the fragment from the incoming - * buffer. */ - memmove(client->client_inbuf, - client->client_inbuf + (len + 4), - client->client_inbuf_used - (len + 4)); + * buffer by moving the rest forward. */ + if ((len + 4) < client->client_inbuf_used) { + memmove(client->client_inbuf, + client->client_inbuf + (len + 4), + client->client_inbuf_used - (len + 4)); + } client->client_inbuf_used -= (len + 4); } if (last) { -- cgit