Skip to content

Commit c99492a

Browse files
Jim8yshargonajara87Wi1l-B0t
authored
Handle null StringBuilder append values (#1903)
Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Alvaro <amjarag@gmail.com> Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>
1 parent c494c2b commit c99492a

4 files changed

Lines changed: 136 additions & 9 deletions

File tree

src/Neo.Compiler.CSharp/MethodConvert/System/SystemCall.StringBuilder.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,19 @@ private static byte ConvertStringBuilderArgument(MethodConvert methodConvert, Se
244244
methodConvert.ConvertExpression(model, ExtractExpression(argument));
245245
byte nestedSlot = methodConvert.AddAnonymousVariable();
246246
methodConvert.AccessSlot(OpCode.STLOC, nestedSlot);
247+
248+
JumpTarget nullBuilder = new();
249+
JumpTarget end = new();
250+
methodConvert.AccessSlot(OpCode.LDLOC, nestedSlot);
251+
methodConvert.IsNull();
252+
methodConvert.JumpIfTrue(nullBuilder);
247253
LoadStringBuilderContent(methodConvert, nestedSlot);
248254
EnsureStringValue(methodConvert);
255+
methodConvert.Jump(end);
256+
nullBuilder.Instruction = methodConvert.Nop();
257+
methodConvert.Push("");
258+
end.Instruction = methodConvert.Nop();
259+
249260
slot = methodConvert.AddAnonymousVariable();
250261
methodConvert.AccessSlot(OpCode.STLOC, slot);
251262
methodConvert.RemoveAnonymousVariable(nestedSlot);

0 commit comments

Comments
 (0)