From 580f62220c5384726fdcd526afeaf5e4954225e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Wed, 6 Feb 2019 10:13:44 +0100 Subject: [PATCH] Fixes #10568: Fix null pointer dereference in address computation. According to https://hownot2code.com/2016/08/18/null-pointer-dereferencing-causes-undefined-behavior/ this was an undefined behaviour. --- compiler/ccgexprs.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 5bcbcda1c..fb2fd89a3 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1123,7 +1123,7 @@ proc genSeqElemAppend(p: BProc, e: PNode, d: var TLoc) = # seq = (typeof seq) incrSeq(&seq->Sup, sizeof(x)); # seq->data[seq->len-1] = x; let seqAppendPattern = if not p.module.compileToCpp: - "($2) #incrSeqV3(&($1)->Sup, $3)" + "($2) #incrSeqV3((TGenericSeq*)($1), $3)" else: "($2) #incrSeqV3($1, $3)" var a, b, dest, tmpL, call: TLoc