summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstefw <stefw@localhost>2009-04-02 03:29:53 +0000
committerstefw <stefw@localhost>2009-04-02 03:29:53 +0000
commit2e8352d203eceebb2b44917b6ddcfc1e26a52002 (patch)
tree50707c2bdb0a58d83b36fb002e9e463ff42515a8
parent49fe9172d0709ec64249715f042ccc0eb5d95308 (diff)
downloadgnome-keyring-2e8352d203eceebb2b44917b6ddcfc1e26a52002.tar.gz
Fix assertion that occurs when shrinking block of secure memory and then expanding again.
svn path=/trunk/; revision=1706
-rw-r--r--ChangeLog5
-rw-r--r--egg/egg-secure-memory.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d51bb761..8e3a60d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-01 Stef Walter <stef@memberwebs.com>
+
+ * egg/egg-secure-memory.c: Fix assertion that occurs when
+ shrinking block of secure memory and then expanding again.
+
2009-03-20 Stef Walter <stef@memberwebs.com>
* configure.in: Quote shell variable properly in configure.in
diff --git a/egg/egg-secure-memory.c b/egg/egg-secure-memory.c
index c2cc7a43..2d584efc 100644
--- a/egg/egg-secure-memory.c
+++ b/egg/egg-secure-memory.c
@@ -625,7 +625,7 @@ sec_realloc (Block *block, void *memory, size_t length)
/* How many words we actually want */
n_words = sec_size_to_words (length) + 2;
- /* Less memory is required */
+ /* Less memory is required than is in the cell */
if (n_words <= cell->n_words) {
/* TODO: No shrinking behavior yet */
@@ -636,7 +636,15 @@ sec_realloc (Block *block, void *memory, size_t length)
VALGRIND_MAKE_MEM_DEFINED (alloc, length);
#endif
- return sec_clear_memory (alloc, valid, length);
+ /*
+ * Even though we may be reusing the same cell, that doesn't
+ * mean that the allocation is shrinking. It could have shrunk
+ * and is now expanding back some.
+ */
+ if (length < valid)
+ return sec_clear_memory (alloc, length, valid);
+ else
+ return alloc;
}
/* Need braaaaaiiiiiinsss... */