[Mono-bugs] [Bug 51347][Nor] Changed - Incorrect string concatenation in string array initializers

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 25 Nov 2003 02:12:53 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by l_m@pacbell.net.

http://bugzilla.ximian.com/show_bug.cgi?id=51347

--- shadow/51347	2003-11-24 23:46:06.000000000 -0500
+++ shadow/51347.tmp.14526	2003-11-25 02:12:53.000000000 -0500
@@ -1,13 +1,13 @@
 Bug#: 51347
 Product: Mono/MCS
 Version: unspecified
 OS: All
 OS Details: 
-Status: RESOLVED   
-Resolution: FIXED
+Status: REOPENED   
+Resolution: 
 Severity: Unknown
 Priority: Normal
 Component: Misc
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: l_m@pacbell.net               
 QAContact: mono-bugs@ximian.com
@@ -72,6 +72,63 @@
 Could you provide more information on the research here?  Why are we
 gettting that extra "C" load in the string concatenation?
 
 (I applied the patch)
 
 Miguel
+
+------- Additional Comments From l_m@pacbell.net  2003-11-25 02:12 -------
+The problem is that Resolve is called multiple times and each time it 
+keeps adding to the args array even if the BinaryMethod is discarded.
+
+The fix is to clone the args before adding a new element. The patch 
+you have applied is not copying the elements, here's another version 
+that will only allocate the object[] once.
+
+Index: expression.cs
+===================================================================
+RCS file: /cvs/public/mcs/mcs/expression.cs,v
+retrieving revision 1.500
+diff -u -b -r1.500 expression.cs
+--- expression.cs	25 Nov 2003 05:26:36 -0000	1.500
++++ expression.cs	25 Nov 2003 06:52:37 -0000
+@@ -2310,15 +2310,18 @@
+ 							//
+ 							if (b.method 
+== TypeManager.string_concat_string_string ||
+ 							     b.method 
+== TypeManager.string_concat_string_string_string){
+-							
+	ArrayList bargs = new ArrayList (b.Arguments.Count);
+-								int 
+count = bargs.Count;
++								int 
+count = b.Arguments.Count;
+ 								
+ 								if 
+(count == 2){
++        							
+	ArrayList bargs = new ArrayList (3);
++                                                                     
+   bargs.AddRange (b.Arguments);
+ 								
+	bargs.Add (new Argument (right, Argument.AType.Expression));
+ 								
+	return new BinaryMethod (
+ 								
+		TypeManager.string_type,
+ 								
+		TypeManager.string_concat_string_string_string, 
+bargs);
+ 								} 
+else if (count == 3){
++        							
+	ArrayList bargs = new ArrayList (4);
++                                                                     
+   bargs.AddRange (b.Arguments);
+ 								
+	bargs.Add (new Argument (right, Argument.AType.Expression));
+ 								
+	return new BinaryMethod (
+ 								
+		TypeManager.string_type,
+