Skip to content

Commit 7a7ba64

Browse files
committed
Only free pathname if we allocated it.
1 parent 4b83ca7 commit 7a7ba64

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/gridftp_hdfs_cksm.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ globus_result_t hdfs_get_checksum_internal(hdfs_handle_t *hdfs_handle, const cha
474474
}
475475

476476
// Not used in this function except in the contents of the error message.
477-
hdfs_handle->pathname = strdup(pathname);
477+
int allocated_pathname;
478+
if ((allocated_pathname = (hdfs_handle->pathname == NULL))) {
479+
hdfs_handle->pathname = strdup(pathname);
480+
}
478481

479482
size_t cksm_len = strlen(hdfs_handle->cksm_root);
480483
size_t path_len = strlen(pathname);
@@ -599,8 +602,9 @@ globus_result_t hdfs_get_checksum_internal(hdfs_handle_t *hdfs_handle, const cha
599602
globus_gfs_log_message(GLOBUS_GFS_LOG_INFO, "Got checksum (%s:%s) for %s.\n", requested_cksm, *cksm_value, filename);
600603
}
601604

602-
if (hdfs_handle->pathname) {
605+
if (allocated_pathname && hdfs_handle->pathname) {
603606
free(hdfs_handle->pathname);
607+
hdfs_handle->pathname = NULL;
604608
}
605609
free(cksm);
606610
free(buffer);

0 commit comments

Comments
 (0)