diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-21 22:58:19 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-04 15:43:13 +0300 |
commit | 8ce8bfb30c64785d0dddfb319e48ff6cbc5f4405 (patch) | |
tree | 6f375a46b6f85ec469e89707a33f28718fe24f60 /include | |
parent | 1705e5d927dba731c135e1192bfdee421829786a (diff) | |
download | grecs-8ce8bfb30c64785d0dddfb319e48ff6cbc5f4405.tar.gz grecs-8ce8bfb30c64785d0dddfb319e48ff6cbc5f4405.tar.bz2 |
Prevent memory leaks when re-processing values of string type.
Port of a3f25ce2 from master.
* include/grecs/table.h (GRECS_CONST): New flag.
* src/tree.c (grecs_string_convert): For string types, free the
old value prior to assigning the new one, unless the GRECS_CONST
flag is set. In any case, clear the GRECS_CONST flag after
assigning new value.
Diffstat (limited to 'include')
-rw-r--r-- | include/grecs/table.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/include/grecs/table.h b/include/grecs/table.h index 4210c6f..d7d0a8c 100644 --- a/include/grecs/table.h +++ b/include/grecs/table.h | |||
@@ -40,12 +40,16 @@ enum grecs_data_type { | |||
40 | grecs_type_null | 40 | grecs_type_null |
41 | }; | 41 | }; |
42 | 42 | ||
43 | #define GRECS_DFLT 0x00 | 43 | #define GRECS_DFLT 0x00 /* Default keyword flags */ |
44 | #define GRECS_AGGR 0x01 | 44 | #define GRECS_AGGR 0x01 /* Multiple entries aggregate */ |
45 | #define GRECS_MULT 0x02 | 45 | #define GRECS_MULT 0x02 /* Statement can appear multiple times */ |
46 | #define GRECS_INAC 0x04 | 46 | #define GRECS_INAC 0x04 /* Inactive keyword */ |
47 | #define GRECS_LIST 0x08 | 47 | #define GRECS_LIST 0x08 /* Value is a list of declared type */ |
48 | #define GRECS_HIDDEN 0x10 | 48 | #define GRECS_HIDDEN 0x10 /* Hidden keyword: don't display in help output */ |
49 | #define GRECS_CONST 0x20 /* For string types: initial value is constant, | ||
50 | don't try to free it before assigning new value. | ||
51 | This flag is cleared after the first assignment. | ||
52 | */ | ||
49 | 53 | ||
50 | enum grecs_callback_command { | 54 | enum grecs_callback_command { |
51 | grecs_callback_section_begin, | 55 | grecs_callback_section_begin, |