]> git.kaiwu.me - njs.git/commitdiff
Align opaque values
authorDmitry Volyntsev <xeioex@nginx.com>
Sun, 13 Sep 2026 19:53:30 +0000 (12:53 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 14 Sep 2026 17:53:52 +0000 (10:53 -0700)
Opaque values are cast to njs_value_t pointers by the public API.  Match
njs_value_t alignment while retaining the four uint32_t filler fields.

UndefinedBehaviorSanitizer reports unaligned njs_value_t accesses.

src/njs.h

index b33a8568081cd5e62b3d7bb2868683f2b661f2c1..b6fa1b47c68a27d809a7177195831c5923b88498 100644 (file)
--- a/src/njs.h
+++ b/src/njs.h
@@ -44,8 +44,9 @@ typedef struct njs_external_s         njs_external_t;
  * sizeof(njs_opaque_value_t) == sizeof(njs_value_t).
  */
 
-typedef struct {
+typedef union {
     uint32_t                        filler[4];
+    uint64_t                        align;
 } njs_opaque_value_t;
 
 /* sizeof(njs_value_t) is 16 bytes. */