]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Defensive coding for ESI stackmember (#1033)
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 5 May 2022 06:42:52 +0000 (06:42 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 6 May 2022 12:40:19 +0000 (12:40 +0000)
Add initializer for the value union in struct stackmember in ESI

Coverity CID 1494364: Uninitialized scalar variable (UNINIT).

src/esi/Expression.cc

index 84fd43c6042cd3cb66a110c82942278b128c49ec..edf2740e87fb19db65884a774b1c9d5c8b16bce2 100644 (file)
@@ -63,15 +63,16 @@ typedef enum {
 } literalhint;
 
 struct _stackmember {
-    evaluate *eval;
-    union {
+    evaluate *eval = nullptr;
+    union Value {
         char *string;
         double floating;
         int integral;
+        Value() { memset(this, 0, sizeof(*this)); }
     } value;
-    literalhint valuestored;
-    evaltype valuetype;
-    int precedence;
+    literalhint valuestored = ESI_LITERAL_INVALID;
+    evaltype valuetype = ESI_EXPR_INVALID;
+    int precedence = 0;
 };
 
 static void cleanmember(stackmember *);