Skip to content

Commit 5e40dd0

Browse files
committed
Work around optimization bug
For some reason, the compiler is optimizing out a memset() that clears the yaml_event_t at the end of yaml_event_delete(), which is called implicitly by yaml_emitter_emit(). As a result, the cleanup at the end of the function ends up performing a double-free. This works around the problem by always assuming that the yaml_event_delete() routine worked properly and just forces the event.type field to zero, thereby preventing any future calls to yaml_event_delete() from attempting to free() memory. Signed-off-by: Stephen Gallagher <[email protected]>
1 parent 51ace79 commit 5e40dd0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

modulemd/include/modulemd-1.0/private/modulemd-yaml.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ typedef gboolean (*ModulemdParsingFunc) (yaml_parser_t *parser,
124124
#define MMD_EMIT_WITH_EXIT(emitter, event, _error, ...) \
125125
do \
126126
{ \
127+
int _ret; \
127128
g_debug ("Emitter event: %s", mmd_yaml_get_event_name ((event)->type)); \
128-
if (!yaml_emitter_emit (emitter, event)) \
129+
_ret = yaml_emitter_emit (emitter, event); \
130+
(event)->type = 0; \
131+
if (!_ret) \
129132
{ \
130133
g_debug (__VA_ARGS__); \
131134
g_set_error (_error, \

0 commit comments

Comments
 (0)