diff --git a/parser/parser_interface.c b/parser/parser_interface.c index 855e09f2f..0d6626d97 100644 --- a/parser/parser_interface.c +++ b/parser/parser_interface.c @@ -597,7 +597,8 @@ int __sd_serialize_profile(int option, Profile *prof) } } - close(fd); + if (fd != -1) + close(fd); if (!prof->hat_table.empty() && option != OPTION_REMOVE) { if (load_flattened_hats(prof, option) == 0)