diff options
author | stefw <stefw@localhost> | 2009-04-02 03:29:53 +0000 |
---|---|---|
committer | stefw <stefw@localhost> | 2009-04-02 03:29:53 +0000 |
commit | 2e8352d203eceebb2b44917b6ddcfc1e26a52002 (patch) | |
tree | 50707c2bdb0a58d83b36fb002e9e463ff42515a8 /egg/egg-secure-memory.c | |
parent | 49fe9172d0709ec64249715f042ccc0eb5d95308 (diff) | |
download | gnome-keyring-2e8352d203eceebb2b44917b6ddcfc1e26a52002.tar.gz |
Fix assertion that occurs when shrinking block of secure memory and then expanding again.
svn path=/trunk/; revision=1706
Diffstat (limited to 'egg/egg-secure-memory.c')
-rw-r--r-- | egg/egg-secure-memory.c | 12 |
1 files changed, 10 insertions, 2 deletions
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... */ |