diff options
author | Daniel Black <daniel.black@au.ibm.com> | 2016-06-13 18:11:31 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-06-14 19:17:29 +0300 |
commit | 0089af8e1c767ed34ff8d92428beacf50fa97e79 (patch) | |
tree | 58494b3600824dc1dba284f77c66f00c54208d29 /mysys | |
parent | cf721d23cc90e7848b0611180b9777d080a1faf6 (diff) | |
download | mariadb-git-0089af8e1c767ed34ff8d92428beacf50fa97e79.tar.gz |
MDEV-9433: [PATCH] cppcheck reported a number of minor coding errors
Fix a bug in testhash.c that caused an out of bounds memory access
when command line parameters specified 0 records to be inserted
in the hashtable.
Signed-off-by: Vicențiu Ciorbaru <vicentiu@mariadb.org>
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/testhash.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mysys/testhash.c b/mysys/testhash.c index ffdaaece770..aa78a2d8c40 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -169,7 +169,9 @@ static int do_test() for (j=0 ; j < 1000 ; j++) if (key1[j] > 1) break; - if (key1[j] > 1) + // j will be 1000 only if we have no keys in the hash. This only happens + // when the parameter recant is set to 0 via command line argument. + if (j < 1000 && key1[j] > 1) { HASH_SEARCH_STATE state; printf("- Testing identical read\n"); |