[vala/0.40] libvaladoc: Don't change the size of an array in-parameter
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] libvaladoc: Don't change the size of an array in-parameter
- Date: Thu, 28 Feb 2019 15:24:21 +0000 (UTC)
commit 14006477b24c9f0a5c0343e0bf004941628ee828
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jan 29 17:05:30 2019 +0100
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.
libvaladoc/markupwriter.vala | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libvaladoc/markupwriter.vala b/libvaladoc/markupwriter.vala
index 28a61ffe7..2fc371ee6 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 ("<");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]