Revision: 693
http://www.exim.org/viewvc/pcre2?view=rev&revision=693
Author: ph10
Date: 2017-03-21 16:25:01 +0000 (Tue, 21 Mar 2017)
Log Message:
-----------
Fix memory leak when deserializing invalid data (Bugzilla 2075).
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_serialize.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2017-03-21 16:18:54 UTC (rev 692)
+++ code/trunk/ChangeLog 2017-03-21 16:25:01 UTC (rev 693)
@@ -71,7 +71,9 @@
10. In pcre2test, explicitly close the file after an error during serialization
or deserialization (the "load" or "save" commands).
+11. Fix memory leak in pcre2_serialize_decode() when the input is invalid.
+
Version 10.23 14-February-2017
------------------------------
Modified: code/trunk/src/pcre2_serialize.c
===================================================================
--- code/trunk/src/pcre2_serialize.c 2017-03-21 16:18:54 UTC (rev 692)
+++ code/trunk/src/pcre2_serialize.c 2017-03-21 16:25:01 UTC (rev 693)
@@ -7,7 +7,7 @@
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016 University of Cambridge
+ New API code Copyright (c) 2016-2017 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -214,7 +214,10 @@
if (dst_re->magic_number != MAGIC_NUMBER ||
dst_re->name_entry_size > MAX_NAME_SIZE + IMM2_SIZE + 1 ||
dst_re->name_count > MAX_NAME_COUNT)
+ {
+ memctl->free(dst_re, memctl->memory_data);
return PCRE2_ERROR_BADSERIALIZEDDATA;
+ }
/* At the moment only one table is supported. */