@@ -340,7 +340,7 @@ void nr_lib_aws_sdk_php_lambda_handle(nr_segment_t* auto_segment,
340
340
341
341
/* reconstruct the ARN */
342
342
nr_aws_lambda_invoke (NR_EXECUTE_ORIG_ARGS , & cloud_attrs );
343
- if (! cloud_attrs .cloud_resource_id ) {
343
+ if (NULL == cloud_attrs .cloud_resource_id ) {
344
344
/* we do not want to instrument if we cannot reconstruct the ARN */
345
345
return ;
346
346
}
@@ -352,6 +352,7 @@ void nr_lib_aws_sdk_php_lambda_handle(nr_segment_t* auto_segment,
352
352
*/
353
353
external_segment = nr_segment_start (NRPRG (txn ), NULL , NULL );
354
354
if (NULL == external_segment ) {
355
+ nr_free (cloud_attrs .cloud_resource_id );
355
356
return ;
356
357
}
357
358
/* re-use start time from auto_segment started in func_begin */
@@ -379,6 +380,7 @@ void nr_lib_aws_sdk_php_lambda_handle(nr_segment_t* auto_segment,
379
380
}
380
381
}
381
382
nr_segment_external_end (& auto_segment , & external_params );
383
+ nr_free (cloud_attrs .cloud_resource_id );
382
384
}
383
385
384
386
/* This stores the compiled regex to parse AWS ARNs. The compilation happens when
@@ -404,6 +406,7 @@ void nr_aws_lambda_invoke(NR_EXECUTE_PROTO, nr_segment_cloud_attrs_t* cloud_attr
404
406
char * qualifier = NULL ;
405
407
zval * qualifier_zval = NULL ;
406
408
char * accountID = NULL ;
409
+ bool using_account_id_ini = false;
407
410
408
411
/* verify arguments */
409
412
if (!nr_php_is_zval_valid_array (call_args )) {
@@ -439,11 +442,17 @@ void nr_aws_lambda_invoke(NR_EXECUTE_PROTO, nr_segment_cloud_attrs_t* cloud_attr
439
442
* Cannot get the needed data. Function name is required in the
440
443
* argument, so this won't happen in normal operation
441
444
*/
445
+ nr_free (function_name );
446
+ nr_free (accountID );
447
+ nr_free (region );
448
+ nr_free (qualifier );
442
449
nr_regex_substrings_destroy (& matches );
443
450
return ;
444
451
}
445
452
if (nr_strempty (accountID )) {
453
+ nr_free (accountID );
446
454
accountID = NRINI (aws_account_id );
455
+ using_account_id_ini = true;
447
456
}
448
457
if (nr_strempty (region )) {
449
458
region_zval
@@ -474,6 +483,12 @@ void nr_aws_lambda_invoke(NR_EXECUTE_PROTO, nr_segment_cloud_attrs_t* cloud_attr
474
483
}
475
484
476
485
nr_regex_substrings_destroy (& matches );
486
+ nr_free (function_name );
487
+ if (!using_account_id_ini ) {
488
+ nr_free (accountID );
489
+ }
490
+ nr_free (region );
491
+ nr_free (qualifier );
477
492
nr_php_zval_free (& region_zval );
478
493
nr_php_zval_free (& qualifier_zval );
479
494
}
0 commit comments