Skip to content

Commit f928e44

Browse files
author
Felipe Zimmerle
committed
Revert "Fix memory leak in msc_rules_* C APIs"
This reverts commit 58701e7. It was breaking the multi-thread examples.
1 parent b85a645 commit f928e44

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/rules.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ extern "C" int msc_rules_merge(Rules *rules_dst,
321321
Rules *rules_from, const char **error) {
322322
int ret = rules_dst->merge(rules_from);
323323
if (ret < 0) {
324-
*error = rules_dst->getParserError().c_str();
324+
*error = strdup(rules_dst->getParserError().c_str());
325325
}
326326
return ret;
327327
}
@@ -331,7 +331,7 @@ extern "C" int msc_rules_add_remote(Rules *rules,
331331
const char *key, const char *uri, const char **error) {
332332
int ret = rules->loadRemote(key, uri);
333333
if (ret < 0) {
334-
*error = rules->getParserError().c_str();
334+
*error = strdup(rules->getParserError().c_str());
335335
}
336336
return ret;
337337
}
@@ -341,7 +341,7 @@ extern "C" int msc_rules_add_file(Rules *rules, const char *file,
341341
const char **error) {
342342
int ret = rules->loadFromUri(file);
343343
if (ret < 0) {
344-
*error = rules->getParserError().c_str();
344+
*error = strdup(rules->getParserError().c_str());
345345
}
346346
return ret;
347347
}
@@ -351,7 +351,7 @@ extern "C" int msc_rules_add(Rules *rules, const char *plain_rules,
351351
const char **error) {
352352
int ret = rules->load(plain_rules);
353353
if (ret < 0) {
354-
*error = rules->getParserError().c_str();
354+
*error = strdup(rules->getParserError().c_str());
355355
}
356356
return ret;
357357
}

0 commit comments

Comments
 (0)