summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt
diff options
context:
space:
mode:
authorpavook <[email protected]>2026-04-17 15:40:13 +0300
committerpavook <[email protected]>2026-04-17 16:37:33 +0300
commit70edb604e93a313f36e434fd25b312527d59f361 (patch)
treefaacc8c3ac1d65c296a474dff47c56cee6728b58 /library/cpp/yt
parenta2fc20748143708512d826a79b6e96b0964b0032 (diff)
Fix some use-after-move bugs
commit_hash:4bc357937e76b2b082671bb0f67ac3012ee4dbca
Diffstat (limited to 'library/cpp/yt')
-rw-r--r--library/cpp/yt/error/error-inl.h6
-rw-r--r--library/cpp/yt/error/error.h1
-rw-r--r--library/cpp/yt/memory/ref-inl.h2
-rw-r--r--library/cpp/yt/string/format-inl.h2
4 files changed, 6 insertions, 5 deletions
diff --git a/library/cpp/yt/error/error-inl.h b/library/cpp/yt/error/error-inl.h
index 68c041afaf5..1542d008f58 100644
--- a/library/cpp/yt/error/error-inl.h
+++ b/library/cpp/yt/error/error-inl.h
@@ -276,7 +276,7 @@ template <class T>
template <class TErrorLike>
TErrorOr<T>::TErrorOr(TErrorLike&& other) noexcept
requires std::is_same_v<TErrorLike, TError>
- : TError(std::move(other))
+ : TError(std::forward<TErrorLike>(other))
{
YT_VERIFY(!IsOK());
}
@@ -530,7 +530,7 @@ TException&& operator <<= (TException&& ex, const TError& error)
{
YT_VERIFY(!error.IsOK());
ex.Error() = error;
- return std::move(ex);
+ return std::forward<TException>(ex);
}
template <class TException>
@@ -539,7 +539,7 @@ TException&& operator <<= (TException&& ex, TError&& error)
{
YT_VERIFY(!error.IsOK());
ex.Error() = std::move(error);
- return std::move(ex);
+ return std::forward<TException>(ex);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/yt/error/error.h b/library/cpp/yt/error/error.h
index 044e792f175..2bd829b28fa 100644
--- a/library/cpp/yt/error/error.h
+++ b/library/cpp/yt/error/error.h
@@ -336,6 +336,7 @@ struct TErrorAdaptor
};
// Make these to correctly forward TError to Wrap call.
+// NB(pavook): TErrorLike is intentionally always stolen (even if the caller passes it as an lvalue).
template <class TErrorLike, class U>
requires
std::derived_from<std::remove_cvref_t<TErrorLike>, TError> &&
diff --git a/library/cpp/yt/memory/ref-inl.h b/library/cpp/yt/memory/ref-inl.h
index 19e835b023d..34a0e365c19 100644
--- a/library/cpp/yt/memory/ref-inl.h
+++ b/library/cpp/yt/memory/ref-inl.h
@@ -489,7 +489,7 @@ Y_FORCE_INLINE TSharedRefArray::TSharedRefArray(const TParts& parts, TSharedRefA
template <class TParts>
Y_FORCE_INLINE TSharedRefArray::TSharedRefArray(TParts&& parts, TSharedRefArray::TMoveParts)
- : Impl_(NewImpl(parts.size(), 0, GetRefCountedTypeCookie<TSharedRefArrayTag>(), std::move(parts), TSharedRefArray::TMoveParts{}))
+ : Impl_(NewImpl(parts.size(), 0, GetRefCountedTypeCookie<TSharedRefArrayTag>(), std::forward<TParts>(parts), TSharedRefArray::TMoveParts{}))
{ }
Y_FORCE_INLINE TSharedRefArray& TSharedRefArray::operator=(const TSharedRefArray& other)
diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h
index 9900cdcee3c..5d10c823874 100644
--- a/library/cpp/yt/string/format-inl.h
+++ b/library/cpp/yt/string/format-inl.h
@@ -351,7 +351,7 @@ TFormatterWrapper<TFormatter> MakeFormatterWrapper(
TFormatter&& formatter)
{
return TFormatterWrapper<TFormatter>{
- .Formatter = std::move(formatter)
+ .Formatter = std::forward<TFormatter>(formatter)
};
}