Skip to content

Commit

Permalink
firefox: avoid using the highest byte of pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
licy183 committed Jan 14, 2025
1 parent 888d97e commit 3018762
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
65 changes: 65 additions & 0 deletions x11-packages/firefox/0029-fix-tagged-pointer.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
https://github.com/termux/termux-packages/issues/22907

--- a/layout/generic/IntrinsicISizesCache.h
+++ b/layout/generic/IntrinsicISizesCache.h
@@ -131,25 +131,14 @@
};

// If the high bit of mOutOfLine is 1, then it points to an OutOfLineCache.
+ bool mIsOutOfLine = false;
union {
InlineCache mInline;
- struct {
-#ifndef HAVE_64BIT_BUILD
- uintptr_t mPadding = 0;
-#endif
- uintptr_t mOutOfLine = 0;
- };
+ uintptr_t mOutOfLine = 0;
};

- static constexpr uintptr_t kHighBit = uintptr_t(1)
- << (sizeof(void*) * CHAR_BIT - 1);
-
bool IsOutOfLine() const {
-#ifdef HAVE_64BIT_BUILD
- return mOutOfLine & kHighBit;
-#else
- return mPadding & kHighBit;
-#endif
+ return mIsOutOfLine;
}
bool IsInline() const { return !IsOutOfLine(); }
OutOfLineCache* EnsureOutOfLine() {
@@ -159,13 +148,8 @@
auto inlineCache = mInline;
auto* ool = new OutOfLineCache();
ool->mCacheWithoutPercentageBasis = inlineCache;
-#ifdef HAVE_64BIT_BUILD
- MOZ_ASSERT((reinterpret_cast<uintptr_t>(ool) & kHighBit) == 0);
- mOutOfLine = reinterpret_cast<uintptr_t>(ool) | kHighBit;
-#else
mOutOfLine = reinterpret_cast<uintptr_t>(ool);
- mPadding = kHighBit;
-#endif
+ mIsOutOfLine = true;
MOZ_ASSERT(IsOutOfLine());
return ool;
}
@@ -174,16 +158,10 @@
if (!IsOutOfLine()) {
return nullptr;
}
-#ifdef HAVE_64BIT_BUILD
- return reinterpret_cast<OutOfLineCache*>(mOutOfLine & ~kHighBit);
-#else
return reinterpret_cast<OutOfLineCache*>(mOutOfLine);
-#endif
}
};

-static_assert(sizeof(IntrinsicISizesCache) == 8, "Unexpected cache size");
-
} // namespace mozilla

#endif
1 change: 1 addition & 0 deletions x11-packages/firefox/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Mozilla Firefox web browser"
TERMUX_PKG_LICENSE="MPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="134.0"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://archive.mozilla.org/pub/firefox/releases/${TERMUX_PKG_VERSION}/source/firefox-${TERMUX_PKG_VERSION}.source.tar.xz
TERMUX_PKG_SHA256=ca88068bd72784c10de16df62359b2dc354672a1a427b4fd6a5fcdb34c06457e
# ffmpeg and pulseaudio are dependencies through dlopen(3):
Expand Down

0 comments on commit 3018762

Please sign in to comment.