Skip to content

Commit 7f3d11b

Browse files
committed
fix: ensure moebius_ works even when char is unsigned
Use SBYTE for signed 1-byte integers to avoid issues in environments where char defaults to unsigned, e.g., ARM64 Linux.
1 parent 1d5e40b commit 7f3d11b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sources/reken.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,7 +3729,7 @@ WORD Moebius(PHEAD WORD nn)
37293729
{
37303730
WORD i,n = nn, x;
37313731
LONG newsize;
3732-
char *newtable, mu;
3732+
SBYTE *newtable, mu;
37333733
#if ( BITSINWORD == 32 )
37343734
if ( AR.notfirstprime == 0 ) StartPrimeList(BHEAD0);
37353735
#endif
@@ -3742,7 +3742,7 @@ WORD Moebius(PHEAD WORD nn)
37423742
if ( AR.moebiustablesize <= 0 ) { newsize = (LONG)nn + 20; }
37433743
else { newsize = (LONG)nn*2; }
37443744
if ( newsize > MAXPOSITIVE ) newsize = MAXPOSITIVE;
3745-
newtable = (char *)Malloc1(newsize*sizeof(char),"Moebius");
3745+
newtable = (SBYTE *)Malloc1(newsize*sizeof(SBYTE),"Moebius");
37463746
for ( i = 0; i < AR.moebiustablesize; i++ ) newtable[i] = AR.moebiustable[i];
37473747
for ( ; i < newsize; i++ ) newtable[i] = 2;
37483748
if ( AR.moebiustablesize > 0 ) M_free(AR.moebiustable,"Moebius");

sources/structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ struct R_const {
20372037
WORD *CompressPointer; /* (R) */
20382038
COMPAREDUMMY CompareRoutine;
20392039
ULONG *wranfia;
2040-
char *moebiustable;
2040+
SBYTE *moebiustable;
20412041

20422042
LONG OldTime; /* (R) Zero time. Needed in timer. */
20432043
LONG InInBuf; /* (R) Characters in input buffer. Scratch files. */

0 commit comments

Comments
 (0)