From 063a9ae7a65cebdf1cc128da9815c05f91a2a996 Mon Sep 17 00:00:00 2001 From: Magnus Edenhill Date: Fri, 8 Oct 2021 14:55:41 +0200 Subject: [PATCH] Mock push_request_errors() appended the errors in reverse order --- src/rdkafka_mock.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rdkafka_mock.c b/src/rdkafka_mock.c index 72ca3b429b..468de2cece 100644 --- a/src/rdkafka_mock.c +++ b/src/rdkafka_mock.c @@ -1608,6 +1608,7 @@ rd_kafka_mock_push_request_errors_array (rd_kafka_mock_cluster_t *mcluster, const rd_kafka_resp_err_t *errors) { rd_kafka_mock_error_stack_t *errstack; size_t totcnt; + size_t i; mtx_lock(&mcluster->lock); @@ -1622,8 +1623,8 @@ rd_kafka_mock_push_request_errors_array (rd_kafka_mock_cluster_t *mcluster, sizeof(*errstack->errs)); } - while (cnt > 0) { - errstack->errs[errstack->cnt].err = errors[--cnt]; + for (i = 0 ; i < cnt ; i++) { + errstack->errs[errstack->cnt].err = errors[i]; errstack->errs[errstack->cnt++].rtt = 0; }