Skip to content

Commit 765fe13

Browse files
committed
fix issues reported by Clang Static Analyzer (second atempt)
1 parent 16890cf commit 765fe13

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/pqc/mlkem.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,16 @@ static void s_mlkem_basemul(ishort16 r[2], const ishort16 a[2], const ishort16 b
143143

144144
static ulong32 s_mlkem_load32_le(const unsigned char *x)
145145
{
146-
return (ulong32)x[0]
147-
| (ulong32)x[1] << 8
148-
| (ulong32)x[2] << 16
149-
| (ulong32)x[3] << 24;
146+
ulong32 r;
147+
LOAD32L(r, x);
148+
return r;
150149
}
151150

152151
static ulong32 s_mlkem_load24_le(const unsigned char *x)
153152
{
154-
return (ulong32)x[0]
155-
| (ulong32)x[1] << 8
156-
| (ulong32)x[2] << 16;
153+
return ((ulong32)(x[0] & 255))
154+
| ((ulong32)(x[1] & 255) << 8)
155+
| ((ulong32)(x[2] & 255) << 16);
157156
}
158157

159158
static void s_mlkem_cbd2(mlkem_poly *r, const unsigned char *buf)

0 commit comments

Comments
 (0)