summaryrefslogtreecommitdiff
path: root/libvaladoc/markupwriter.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-01-29 17:05:30 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2019-01-29 18:47:43 +0100
commita0d437af1ef37cdf7f985d7aa856b3bdb9eeeb9b (patch)
tree33fe9b02e5b222675b1f90f7d198ed80f45f95de /libvaladoc/markupwriter.vala
parent9c130ffe0e099a722cb21ba3102f8c6ab40e26da (diff)
downloadvala-a0d437af1ef37cdf7f985d7aa856b3bdb9eeeb9b.tar.gz
libvaladoc: Don't change the size of an array in-parameter
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.
Diffstat (limited to 'libvaladoc/markupwriter.vala')
-rw-r--r--libvaladoc/markupwriter.vala10
1 files changed, 6 insertions, 4 deletions
diff --git a/libvaladoc/markupwriter.vala b/libvaladoc/markupwriter.vala
index b796aa5b7..578701436 100644
--- a/libvaladoc/markupwriter.vala
+++ b/libvaladoc/markupwriter.vala
@@ -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 ("<");