[geary] Heap access violation in random_string(): Bug #741842
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Heap access violation in random_string(): Bug #741842
- Date: Mon, 22 Dec 2014 20:29:55 +0000 (UTC)
commit c2380abff29a7c5209c57d18bc90a960d79366ab
Author: Sergey Shnatsel Davidoff <sergey elementaryos org>
Date: Mon Dec 22 12:28:13 2014 -0800
Heap access violation in random_string(): Bug #741842
Needed to allocate space for terminating NUL.
src/client/util/util-random.vala | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/client/util/util-random.vala b/src/client/util/util-random.vala
index e8939f4..2310185 100644
--- a/src/client/util/util-random.vala
+++ b/src/client/util/util-random.vala
@@ -7,9 +7,10 @@
private string random_string(int length) {
// No upper case letters, since request gets lower-cased.
string chars = "abcdefghijklmnopqrstuvwxyz";
- char[] random = new char[length];
+ char[] random = new char[length+1]; //leave room for terminating null
for (int i = 0; i < length; i++)
random[i] = chars[Random.int_range(0, chars.length)];
+ random[length] = '\0'; //make sure the string is null-terminated
return (string) random;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]