From 32442590b9ba9dcf60e15a5248cf2d15e66d458e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 17 Apr 2007 15:34:27 -0700 Subject: [PATCH] Avoid unnecessary (and potentially dangerous) memmove --- mnemon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); -- 2.43.0