[gmime-devel] [PATCH] use size_t for pointer math in parser_scan_content()



When on a 64-bit Windows system (compiled with VS 2015), we hit a
memory access violation, due to derefferencing a miscalculated pointer
location.

The problem was resolved with the following patch.

---
 gmime/gmime-parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gmime/gmime-parser.c b/gmime/gmime-parser.c
index 092279cc..c864aa4d 100644
--- a/gmime/gmime-parser.c
+++ b/gmime/gmime-parser.c
@@ -1481,7 +1481,7 @@ parser_scan_content (GMimeParser *parser, GMimeStream *content, gboolean *empty)
                priv->midline = FALSE;
                
                while (inptr < inend) {
-                       aligned = (char *) (((long) (inptr + 3)) & ~3);
+                       aligned = (char *) (((size_t) (inptr + 3)) & ~3);
                        start = inptr;
                        
                        /* Note: see optimization comment [1] */
-- 
2.14.2



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