Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double free when accessing .AsBoxed() on Pod with 0 refcount #7659

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/library/yql/parser/pg_wrapper/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ inline NKikimr::NUdf::TUnboxedValuePod AnyDatumToPod(Datum datum, bool passByVal
}

inline Datum PointerDatumFromPod(const NKikimr::NUdf::TUnboxedValuePod& value) {
return (Datum)(((const NKikimr::NMiniKQL::TMkqlPAllocHeader*)value.AsBoxed().Get()) + 1);
return (Datum)(((const NKikimr::NMiniKQL::TMkqlPAllocHeader*)value.AsRawBoxed().Get()) + 1);
}

inline Datum PointerDatumFromItem(const NKikimr::NUdf::TBlockItem& value) {
Expand Down
2 changes: 2 additions & 0 deletions ydb/library/yql/public/udf/udf_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ friend class TUnboxedValue;

inline TStringValue AsStringValue() const;
inline IBoxedValuePtr AsBoxed() const;
inline TStringValue::TData* AsRawStringValue() const;
inline IBoxedValue* AsRawBoxed() const;
inline bool UniqueBoxed() const;

// special values
Expand Down
12 changes: 12 additions & 0 deletions ydb/library/yql/public/udf/udf_value_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ inline IBoxedValuePtr TUnboxedValuePod::AsBoxed() const
return IBoxedValuePtr(Raw.Boxed.Value);
}

inline TStringValue::TData* TUnboxedValuePod::AsRawStringValue() const
{
UDF_VERIFY(IsString(), "Value is not a string");
return Raw.String.Value;
}

inline IBoxedValue* TUnboxedValuePod::AsRawBoxed() const
{
UDF_VERIFY(IsBoxed(), "Value is not boxed");
return Raw.Boxed.Value;
}

inline bool TUnboxedValuePod::UniqueBoxed() const
{
UDF_VERIFY(IsBoxed(), "Value is not boxed");
Expand Down
Loading