[gmime] Fixed GMimeFilter to properly alloc the outreal and backbuf buffers



commit ece51ab982b343f22a125063b1c0ba0c7c4e8c29
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Wed Dec 13 13:10:14 2017 -0500

    Fixed GMimeFilter to properly alloc the outreal and backbuf buffers
    
    When requesting a backup our output buffer of size 0,
    the previous logic would no-op thus allowing said
    buffers to remain NULL if not already allocated.
    
    This would break the expectation that the filtered output
    buffer would never be set to NULL.

 gmime/gmime-filter.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gmime/gmime-filter.c b/gmime/gmime-filter.c
index 121204d..e28a2fc 100644
--- a/gmime/gmime-filter.c
+++ b/gmime/gmime-filter.c
@@ -299,7 +299,7 @@ g_mime_filter_backup (GMimeFilter *filter, const char *data, size_t length)
 {
        g_return_if_fail (GMIME_IS_FILTER (filter));
        
-       if (filter->backsize < length) {
+       if (!filter->backbuf || filter->backsize < length) {
                /* g_realloc copies data, unnecessary overhead */
                g_free (filter->backbuf);
                filter->backbuf = g_malloc (length + BACK_HEAD);
@@ -324,7 +324,7 @@ g_mime_filter_set_size (GMimeFilter *filter, size_t size, gboolean keep)
 {
        g_return_if_fail (GMIME_IS_FILTER (filter));
        
-       if (filter->outsize < size) {
+       if (!filter->outreal || filter->outsize < size) {
                size_t offset = filter->outptr - filter->outreal;
                
                if (keep) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]