From b9781c4903f95a9e12447a3c1be8b754e8865997 Mon Sep 17 00:00:00 2001 From: Shahar Mike Date: Sun, 5 Nov 2023 13:31:28 +0200 Subject: [PATCH] fix(test): Don't access null pointer (#2126) This caused a UBSan warning to be printed in test `DflyEngineTest.Bug207` ``` /usr/include/c++/11/bits/stl_vector.h:1046:34: runtime error: reference binding to null pointer of type 'struct value_type' ``` --- src/server/db_slice.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server/db_slice.cc b/src/server/db_slice.cc index 7131ef2b9..39d611083 100644 --- a/src/server/db_slice.cc +++ b/src/server/db_slice.cc @@ -1183,9 +1183,12 @@ finish: // send the deletion to the replicas. // fiber preemption could happen in this phase. vector args(keys_to_journal.begin(), keys_to_journal.end()); - ArgSlice delete_args(&args[0], args.size()); - if (auto journal = owner_->journal(); journal) { - journal->RecordEntry(0, journal::Op::EXPIRED, db_ind, 1, make_pair("DEL", delete_args), false); + if (!args.empty()) { + ArgSlice delete_args(&args[0], args.size()); + if (auto journal = owner_->journal(); journal) { + journal->RecordEntry(0, journal::Op::EXPIRED, db_ind, 1, make_pair("DEL", delete_args), + false); + } } auto time_finish = absl::GetCurrentTimeNanos();