@@ -1042,32 +1042,35 @@ static void nr_get_composer_package_information() {
1042
1042
}
1043
1043
}
1044
1044
1045
- static bool nr_execute_autoload_is_composer (const char * filename , const size_t filename_len ) {
1045
+ static bool nr_execute_autoload_is_composer (const char * filename ) {
1046
1046
#define COMPOSER_MAGIC_FILE "composer/autoload_real.php"
1047
+ #define COMPOSER_MAGIC_FILE_LEN (sizeof(COMPOSER_MAGIC_FILE) - 1)
1047
1048
char * vendor_path = NULL ; // result of dirname(filename)
1048
1049
char * composer_magic_file = NULL ; // vendor_path + COMPOSER_MAGIC_FILE
1049
1050
char * cp = NULL ;
1050
1051
bool composer_detected = false;
1051
1052
1052
1053
// vendor_path = dirname(filename):
1053
- // 1. allocate space on stack
1054
- vendor_path = nr_alloca (filename_len + 1 );
1055
- // 2. copy filename to vendor_path
1056
- nr_strcpy (vendor_path , filename );
1057
- // 3. // find last occurence of '/' in vendor_path
1054
+ // 1. copy filename to vendor_path
1055
+ vendor_path = nr_strdup (filename );
1056
+ // 2. // find last occurence of '/' in vendor_path
1058
1057
cp = nr_strrchr (vendor_path , '/' );
1059
- // 4 . replace '/' with '\0' to get the directory path
1058
+ // 3 . replace '/' with '\0' to get the directory path
1060
1059
* cp = '\0' ;
1061
1060
1062
1061
// composer_magic_file = vendor_path + "/composer/autoload_real.php"
1063
- composer_magic_file = nr_str_append (vendor_path , COMPOSER_MAGIC_FILE , "/" );
1062
+ cp = composer_magic_file = nr_malloc (nr_strlen (vendor_path ) + COMPOSER_MAGIC_FILE_LEN + 2 );
1063
+ cp = nr_strcpy (cp , vendor_path );
1064
+ * cp ++ = '/' ;
1065
+ cp = nr_strcpy (cp , COMPOSER_MAGIC_FILE );
1064
1066
1065
1067
if (0 == nr_access (composer_magic_file , F_OK | R_OK )) {
1066
1068
nrl_debug (NRL_INSTRUMENT , "detected composer with %s" , composer_magic_file );
1067
1069
composer_detected = true;
1068
1070
nr_fw_support_add_library_supportability_metric (NRPRG (txn ), "Composer" );
1069
1071
}
1070
1072
1073
+ nr_free (vendor_path );
1071
1074
nr_free (composer_magic_file );
1072
1075
return composer_detected ;
1073
1076
}
@@ -1085,7 +1088,7 @@ static void nr_execute_handle_autoload(const char* filename, const size_t filena
1085
1088
NRPRG (txn )-> composer_info .autoload_detected = true;
1086
1089
nr_fw_support_add_library_supportability_metric (NRPRG (txn ), "Autoloader" );
1087
1090
1088
- NRPRG (txn )-> composer_info .composer_detected = nr_execute_autoload_is_composer (filename , filename_len );
1091
+ NRPRG (txn )-> composer_info .composer_detected = nr_execute_autoload_is_composer (filename );
1089
1092
}
1090
1093
}
1091
1094
0 commit comments