From 67af468b7d74b793ed1e442c89dbee83e67c8894 Mon Sep 17 00:00:00 2001 From: SteveMcNeill Date: Mon, 22 Oct 2018 01:02:48 -0400 Subject: [PATCH] Fix memory leak with PRINT USING When USING follows another print in the same statement (such as PRINT "123"; USING "###"; 456), it created a memory leak due to the temp variable being created twice and only freed once. This patch corrects that issue. --- source/qb64.bas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index 3e646b49f..e3a6153ef 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -22335,7 +22335,7 @@ SUB xprint (a$, ca$, n) IF puformat$ = "" THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB IF i = n THEN Give_Error "Expected PRINT USING formatstring ; ...": EXIT SUB 'create build string - PRINT #12, "tqbs=qbs_new(0,0);" + IF TQBSset = 0 THEN PRINT #12, "tqbs=qbs_new(0,0);" 'set format start/index variable PRINT #12, "tmp_long=0;" 'scan format from beginning @@ -22439,6 +22439,7 @@ SUB xprint (a$, ca$, n) e$ = "" last = 0 PRINT #12, "tqbs=qbs_new(0,0);" 'initialize the temp string + TQBSset = -1 'set the temporary flag so we don't create a temp string twice, in case USING comes after something FOR i = 2 TO n a2$ = getelement(ca$, i) IF a2$ = "(" THEN b = b + 1