]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
fix some UB
authorDale Weiler <weilercdale@gmail.com>
Fri, 1 Dec 2017 18:55:19 +0000 (13:55 -0500)
committerDale Weiler <weilercdale@gmail.com>
Fri, 1 Dec 2017 18:55:19 +0000 (13:55 -0500)
parser.cpp
stat.cpp

index 7e552325d544caf5ebb5a955bbf933d80f8f0926..9bfd7517a26aea26b9671f362f6e9be58dcdfd50 100644 (file)
@@ -347,7 +347,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
     const oper_info *op;
     lex_ctx_t ctx;
     ast_expression *out = nullptr;
-    ast_expression *exprs[3];
+    ast_expression *exprs[3] = { 0, 0, 0 };
     ast_block      *blocks[3];
     ast_binstore   *asbinstore;
     size_t i, assignop, addop, subop;
index 1797536ca9ee20bbb2fcb6c4df7cd7fa4ee3c133..5f85a1a24873892586aa99ec7e342aa281c683f2 100644 (file)
--- a/stat.cpp
+++ b/stat.cpp
@@ -28,11 +28,12 @@ char *stat_mem_strdup(const char *src, bool empty) {
  * The reallocate function for resizing vectors.
  */
 void _util_vec_grow(void **a, size_t i, size_t s) {
-    vector_t *d = vec_meta(*a);
+    vector_t *d = nullptr;
     size_t m = 0;
     void *p = nullptr;
 
     if (*a) {
+        d = vec_meta(*a);
         m = 2 * d->allocated + i;
         p = mem_r(d, s * m + sizeof(vector_t));
     } else {