diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-18 20:26:52 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-18 20:26:52 (GMT) |
commit | 0bcca87681ea390671d67a96f771697c9f5ff3be (patch) | |
tree | 0048b5237a0c6e6c25fc412779c3197ccd88c569 /generic/tclLink.c | |
parent | 90a23f176d6423227cc2fd2be8cd3a88ceb1c088 (diff) | |
download | tcl-0bcca87681ea390671d67a96f771697c9f5ff3be.zip tcl-0bcca87681ea390671d67a96f771697c9f5ff3be.tar.gz tcl-0bcca87681ea390671d67a96f771697c9f5ff3be.tar.bz2 |
Backout [52a52a65f0], let's see if this fixes the Windows crash
Diffstat (limited to 'generic/tclLink.c')
-rw-r--r-- | generic/tclLink.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/generic/tclLink.c b/generic/tclLink.c index 397c9bc..1973067 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -537,10 +537,15 @@ GetUWide( } else if (type == TCL_NUMBER_BIG) { mp_int *numPtr = (mp_int *)clientData; Tcl_WideUInt value = 0; + union { + Tcl_WideUInt value; + unsigned char bytes[sizeof(Tcl_WideUInt)]; + } scratch; size_t numBytes; + unsigned char *bytes = scratch.bytes; - if (numPtr->sign || (MP_OKAY != mp_pack(&value, 1, - &numBytes, 0, sizeof(Tcl_WideUInt), 0, 0, numPtr))) { + if (numPtr->sign || (MP_OKAY != mp_to_ubin(numPtr, + bytes, sizeof(Tcl_WideUInt), &numBytes))) { /* * If the sign bit is set (a negative value) or if the value * can't possibly fit in the bits of an unsigned wide, there's @@ -548,6 +553,16 @@ GetUWide( */ return 1; } +#ifndef WORDS_BIGENDIAN + while (numBytes-- > 0) { + value = (value << CHAR_BIT) | *bytes++; + } +#else /* WORDS_BIGENDIAN */ + /* + * Big-endian can read the value directly. + */ + value = scratch.value; +#endif /* WORDS_BIGENDIAN */ *uwidePtr = value; return 0; } |