Skip to content

Commit 9500752

Browse files
committed
fix: clean up mem freeing
1 parent 2a7da47 commit 9500752

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
@@ -605,6 +605,13 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_clean) {
605605
NR_PHP_WRAPPER_END
606606
#endif // OAPI
607607

608+
#define NR_FREE_HOOK_MEM \
609+
nr_free(hook_str); \
610+
nr_free(class_str); \
611+
nr_free(method_str); \
612+
nr_free(module_str); \
613+
nr_free(hookpath);
614+
608615
/*
609616
* Purpose: Instrument Drupal Attribute Hooks for Drupal 11.1+
610617
*
@@ -641,6 +648,7 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {
641648
nrl_warning(NRL_FRAMEWORK,
642649
"hookImplementationsMap[hook = %s]: invalid value",
643650
NRSAFESTR(ZEND_STRING_VALUE(hook_key)));
651+
NR_FREE_HOOK_MEM
644652
return false;
645653
}
646654

@@ -652,24 +660,22 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {
652660
nrl_warning(NRL_FRAMEWORK,
653661
"hookImplementationsMap[class = %s]: invalid value",
654662
NRSAFESTR(ZEND_STRING_VALUE(class_key)));
663+
NR_FREE_HOOK_MEM
655664
return false;
656665
}
657666

658667
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(class_val), key_num, method_key,
659668
module_val) {
660669
(void)key_num;
661670

662-
nr_free(hook_str);
663-
nr_free(class_str);
664-
nr_free(method_str);
665-
nr_free(module_str);
666-
nr_free(hookpath);
671+
NR_FREE_HOOK_MEM
667672

668673
if ((NULL == method_key)
669674
|| (0 == nr_php_is_zval_valid_string(module_val))) {
670675
nrl_warning(NRL_FRAMEWORK,
671676
"hookImplementationsMap[method = %s]: invalid value",
672677
NRSAFESTR(ZEND_STRING_VALUE(method_key)));
678+
NR_FREE_HOOK_MEM
673679
return false;
674680
}
675681

@@ -699,19 +705,16 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {
699705
} else {
700706
nrl_warning(NRL_FRAMEWORK,
701707
"hookImplementationsMap property not a valid array");
708+
NR_FREE_HOOK_MEM
702709
return false;
703710
}
704711
} else {
705712
nrl_warning(NRL_FRAMEWORK, "NULL hookImplementationsMap object property");
713+
NR_FREE_HOOK_MEM
706714
return false;
707715
}
708716

709-
nr_free(hook_str);
710-
nr_free(class_str);
711-
nr_free(method_str);
712-
nr_free(module_str);
713-
nr_free(hookpath);
714-
717+
NR_FREE_HOOK_MEM
715718
return true;
716719
}
717720

0 commit comments

Comments
 (0)