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.
This commit is contained in:
Michał Zieliński
2019-02-06 10:13:44 +01:00
parent 2e880c726b
commit 580f62220c

View File

@@ -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