]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: Don't change the size of an array in-parameter
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 29 Jan 2019 16:05:30 +0000 (17:05 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 29 Jan 2019 17:47:43 +0000 (18:47 +0100)
Avoid a possible memory issue while the resize of an array reference is
possible, the new length can't be propagated back to the caller.

Issue an warning for unexpected string lengths.

libvaladoc/markupwriter.vala

index b796aa5b72551a03c8acabd08fa08cad1afa4b4f..5787014366a1577774cd1e878d6325e480035f5a 100644 (file)
@@ -114,8 +114,9 @@ public class Valadoc.MarkupWriter {
                check_column (name);
 
                if (attributes.length % 2 != 0) {
-                       attributes.resize (attributes.length+1);
-                       attributes[attributes.length-1] = "";
+                       warning ("Given attributes array is not a list of pairs (name and value)");
+                       // This only effects array length of this in-parameter in this scope
+                       attributes.length -= 1;
                }
 
                var content = new StringBuilder ("<");
@@ -144,8 +145,9 @@ public class Valadoc.MarkupWriter {
                check_column (name);
 
                if (attributes.length % 2 != 0) {
-                       attributes.resize (attributes.length+1);
-                       attributes[attributes.length-1] = "";
+                       warning ("Given attributes array is not a list of pairs (name and value)");
+                       // This only effects array length of this in-parameter in this scope
+                       attributes.length -= 1;
                }
 
                var content = new StringBuilder ("<");