Skip to content

Commit fd3f639

Browse files
committed
fix memleak - don't leave vendor_path dangling
`vendor_path` needs to be freed when an error occurs.
1 parent 80fdbdd commit fd3f639

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

agent/lib_composer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,27 +207,28 @@ void nr_composer_handle_autoload(const char* filename) {
207207
COMPOSER_MAGIC_FILE_1)) {
208208
nrl_verbosedebug(NRL_FRAMEWORK, "'%s' not found in '%s'",
209209
COMPOSER_MAGIC_FILE_1, vendor_path);
210-
return;
210+
goto leave;
211211
}
212212

213213
if (!nr_execute_handle_autoload_composer_file_exists(vendor_path,
214214
COMPOSER_MAGIC_FILE_2)) {
215215
nrl_verbosedebug(NRL_FRAMEWORK, "'%s' not found in '%s'",
216216
COMPOSER_MAGIC_FILE_2, vendor_path);
217-
return;
217+
goto leave;
218218
}
219219

220220
if (!nr_execute_handle_autoload_composer_file_exists(vendor_path,
221221
COMPOSER_MAGIC_FILE_3)) {
222222
nrl_verbosedebug(NRL_FRAMEWORK, "'%s' not found in '%s'",
223223
COMPOSER_MAGIC_FILE_3, vendor_path);
224-
return;
224+
goto leave;
225225
}
226226

227227
nrl_verbosedebug(NRL_FRAMEWORK, "detected composer");
228228
NRPRG(txn)->composer_info.composer_detected = true;
229229
nr_fw_support_add_library_supportability_metric(NRPRG(txn), "Composer");
230230

231231
nr_execute_handle_autoload_composer_get_packages_information(vendor_path);
232+
leave:
232233
nr_free(vendor_path);
233234
}

0 commit comments

Comments
 (0)