From: Carl Worth Date: Tue, 17 Apr 2007 22:34:27 +0000 (-0700) Subject: Avoid unnecessary (and potentially dangerous) memmove X-Git-Url: https://git.cworth.org/git?p=mnemon;a=commitdiff_plain;h=32442590b9ba9dcf60e15a5248cf2d15e66d458e Avoid unnecessary (and potentially dangerous) memmove --- diff --git a/mnemon.c b/mnemon.c index 45e0930..25ba65f 100644 --- a/mnemon.c +++ b/mnemon.c @@ -372,7 +372,8 @@ mnemon_get_bin (mnemon_t *mnemon, bin = &mnemon->bins[i]; /* Make room to insert new bin at its sorted location. */ - memmove (bin + 1, bin, (mnemon->num_bins - i) * sizeof (bin_t)); + if (i < mnemon->num_bins) + memmove (bin + 1, bin, (mnemon->num_bins - i) * sizeof (bin_t)); mnemon->num_bins++; bin_init (bin, count);