#include "../compat/compat.h"
#include "writer.h"
+#if defined(__has_feature)
+# if __has_feature(address_sanitizer)
+# define __SANITIZE_ADDRESS__
+# endif
+#endif
+#ifdef __SANITIZE_ADDRESS__
+# include <sanitizer/lsan_interface.h>
+# define SUPPRESS_LEAK(x) __lsan_ignore_object(x)
+#else
+# define SUPPRESS_LEAK(x)
+#endif
+
/* Readline stuff */
#ifdef HAVE_LIBREADLINE
# if defined(HAVE_READLINE_READLINE_H)
for (lldpctl_map_t *addr_map =
lldpctl_key_get_map(lldpctl_k_med_civicaddress_type);
addr_map->string;
- addr_map++)
+ addr_map++) {
+ const char *tag = strdup(totag(addr_map->string));
+ SUPPRESS_LEAK(tag);
commands_new(
commands_new(
configure_medloc_addr,
- strdup(totag(addr_map->string)), /* TODO: memory leak, happens once */
+ tag,
addr_map->string,
cmd_check_no_env, NULL, addr_map->string),
NULL, addr_map->string,
NULL, cmd_store_env_value_and_pop2, addr_map->string);
+ }
}
/**
lldpctl_key_get_map(lldpctl_k_med_policy_type);
pol_map->string;
pol_map++) {
- char *tag = strdup(totag(pol_map->string)); /* TODO: memory leak, happens once */
+ char *tag = strdup(totag(pol_map->string));
+ SUPPRESS_LEAK(tag);
commands_new(
configure_application,
tag,
lldpctl_key_get_map(lldpctl_k_med_policy_priority);
prio_map->string;
prio_map++) {
- char *tag = strdup(totag(prio_map->string)); /* TODO: memory leak, happens once */
+ char *tag = strdup(totag(prio_map->string));
+ SUPPRESS_LEAK(tag);
commands_new(
priority,
tag, prio_map->string,
lldpctl_key_get_map(key);
prio_map->string;
prio_map++) {
- char *tag = strdup(totag(prio_map->string)); /* TODO: memory leak, happens once */
+ char *tag = strdup(totag(prio_map->string));
+ SUPPRESS_LEAK(tag);
commands_new(
priority,
tag,
class_map->string;
class_map++) {
const char *tag = strdup(totag(class_map->string));
+ SUPPRESS_LEAK(tag);
commands_new(
class,
tag,