Skip to content

Commit ab1d33e

Browse files
committed
fix: clean up mem freeing
1 parent a784009 commit ab1d33e

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

agent/fw_drupal8.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,13 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_clean) {
608608
NR_PHP_WRAPPER_END
609609
#endif // OAPI
610610

611+
#define NR_FREE_HOOK_MEM \
612+
nr_free(hook_str); \
613+
nr_free(class_str); \
614+
nr_free(method_str); \
615+
nr_free(module_str); \
616+
nr_free(hookpath);
617+
611618
/*
612619
* Purpose: Instrument Drupal Attribute Hooks for Drupal 11.1+
613620
*
@@ -644,6 +651,7 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {
644651
nrl_warning(NRL_FRAMEWORK,
645652
"hookImplementationsMap[hook = %s]: invalid value",
646653
NRSAFESTR(ZEND_STRING_VALUE(hook_key)));
654+
NR_FREE_HOOK_MEM
647655
return false;
648656
}
649657

@@ -655,24 +663,22 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {
655663
nrl_warning(NRL_FRAMEWORK,
656664
"hookImplementationsMap[class = %s]: invalid value",
657665
NRSAFESTR(ZEND_STRING_VALUE(class_key)));
666+
NR_FREE_HOOK_MEM
658667
return false;
659668
}
660669

661670
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(class_val), key_num, method_key,
662671
module_val) {
663672
(void)key_num;
664673

665-
nr_free(hook_str);
666-
nr_free(class_str);
667-
nr_free(method_str);
668-
nr_free(module_str);
669-
nr_free(hookpath);
674+
NR_FREE_HOOK_MEM
670675

671676
if ((NULL == method_key)
672677
|| (0 == nr_php_is_zval_valid_string(module_val))) {
673678
nrl_warning(NRL_FRAMEWORK,
674679
"hookImplementationsMap[method = %s]: invalid value",
675680
NRSAFESTR(ZEND_STRING_VALUE(method_key)));
681+
NR_FREE_HOOK_MEM
676682
return false;
677683
}
678684

@@ -702,19 +708,16 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {
702708
} else {
703709
nrl_warning(NRL_FRAMEWORK,
704710
"hookImplementationsMap property not a valid array");
711+
NR_FREE_HOOK_MEM
705712
return false;
706713
}
707714
} else {
708715
nrl_warning(NRL_FRAMEWORK, "NULL hookImplementationsMap object property");
716+
NR_FREE_HOOK_MEM
709717
return false;
710718
}
711719

712-
nr_free(hook_str);
713-
nr_free(class_str);
714-
nr_free(method_str);
715-
nr_free(module_str);
716-
nr_free(hookpath);
717-
720+
NR_FREE_HOOK_MEM
718721
return true;
719722
}
720723

0 commit comments

Comments
 (0)