summaryrefslogtreecommitdiffstats
path: root/js/src/jsexn.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2019-11-02 14:37:22 +0100
committerGitHub <noreply@github.com>2019-11-02 14:37:22 +0100
commit21b3f6247403c06f85e1f45d219f87549862198f (patch)
tree0038ae92f1cc7aaff0b55d6e5ac59efcc28bdf8f /js/src/jsexn.cpp
parentff881bdb6795e0f307b93919f98f454bedde4bb6 (diff)
parenta9dc528a4a7b0aaad5308aff70963485ec3e9bec (diff)
downloadUXP-21b3f6247403c06f85e1f45d219f87549862198f.tar
UXP-21b3f6247403c06f85e1f45d219f87549862198f.tar.gz
UXP-21b3f6247403c06f85e1f45d219f87549862198f.tar.lz
UXP-21b3f6247403c06f85e1f45d219f87549862198f.tar.xz
UXP-21b3f6247403c06f85e1f45d219f87549862198f.zip
Merge pull request #1262 from athenian200/solaris-work
Support Modern Solaris
Diffstat (limited to 'js/src/jsexn.cpp')
-rw-r--r--js/src/jsexn.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp
index 65cc81a1a..3fc9200c1 100644
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -205,7 +205,12 @@ size_t
ExtraMallocSize(JSErrorReport* report)
{
if (report->linebuf())
- return (report->linebufLength() + 1) * sizeof(char16_t);
+ /*
+ * Mozilla bug 1352449. Count with null
+ * terminator and alignment. See CopyExtraData for
+ * the details about alignment.
+ */
+ return (report->linebufLength() + 1) * sizeof(char16_t) + 1;
return 0;
}
@@ -220,10 +225,20 @@ bool
CopyExtraData(JSContext* cx, uint8_t** cursor, JSErrorReport* copy, JSErrorReport* report)
{
if (report->linebuf()) {
+ /*
+ * Make sure cursor is properly aligned for char16_t for platforms
+ * which need it and it's at the end of the buffer on exit.
+ */
+ size_t alignment_backlog = 0;
+ if (size_t(*cursor) % 2)
+ (*cursor)++;
+ else
+ alignment_backlog = 1;
+
size_t linebufSize = (report->linebufLength() + 1) * sizeof(char16_t);
const char16_t* linebufCopy = (const char16_t*)(*cursor);
js_memcpy(*cursor, report->linebuf(), linebufSize);
- *cursor += linebufSize;
+ *cursor += linebufSize + alignment_backlog;
copy->initBorrowedLinebuf(linebufCopy, report->linebufLength(), report->tokenOffset());
}