projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix some undefined behaviour in stack test
[openssl.git]
/
test
/
stack_test.c
diff --git
a/test/stack_test.c
b/test/stack_test.c
index f04f6af013794062f21d315ade229beff364c0e2..43257669661a0898e9c56f9aa8d58be77a9d214c 100644
(file)
--- a/
test/stack_test.c
+++ b/
test/stack_test.c
@@
-57,6
+57,7
@@
static int int_compare(const int *const *a, const int *const *b)
static int test_int_stack(void)
{
static int v[] = { 1, 2, -4, 16, 999, 1, -173, 1, 9 };
static int test_int_stack(void)
{
static int v[] = { 1, 2, -4, 16, 999, 1, -173, 1, 9 };
+ static int notpresent = -1;
const int n = OSSL_NELEM(v);
static struct {
int value;
const int n = OSSL_NELEM(v);
static struct {
int value;
@@
-108,18
+109,26
@@
static int test_int_stack(void)
}
/* find unsorted -- the pointers are compared */
}
/* find unsorted -- the pointers are compared */
- for (i = 0; i < n_finds; i++)
- if (sk_sint_find(s, v + finds[i].unsorted) != finds[i].unsorted) {
+ for (i = 0; i < n_finds; i++) {
+ int *val = (finds[i].unsorted == -1) ? ¬present
+ : v + finds[i].unsorted;
+
+ if (sk_sint_find(s, val) != finds[i].unsorted) {
fprintf(stderr, "test int unsorted find %d\n", i);
goto end;
}
fprintf(stderr, "test int unsorted find %d\n", i);
goto end;
}
+ }
/* find_ex unsorted */
/* find_ex unsorted */
- for (i = 0; i < n_finds; i++)
- if (sk_sint_find_ex(s, v + finds[i].unsorted) != finds[i].unsorted) {
+ for (i = 0; i < n_finds; i++) {
+ int *val = (finds[i].unsorted == -1) ? ¬present
+ : v + finds[i].unsorted;
+
+ if (sk_sint_find_ex(s, val) != finds[i].unsorted) {
fprintf(stderr, "test int unsorted find_ex %d\n", i);
goto end;
}
fprintf(stderr, "test int unsorted find_ex %d\n", i);
goto end;
}
+ }
/* sorting */
if (sk_sint_is_sorted(s)) {
/* sorting */
if (sk_sint_is_sorted(s)) {