Skip to content

Commit

Permalink
Free buffer returned by dat1GetFullName
Browse files Browse the repository at this point in the history
  • Loading branch information
grahambell committed Feb 23, 2023
1 parent ad89af0 commit 233ac3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions datMap.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ datMap(HDSLoc *locator, const char *type_str, const char *mode_str, int ndim,

#if DEBUG_HDS
{
char *name_str;
char * file_str;
char *name_str = NULL;
char *file_str = NULL;
const char * reason;
name_str = dat1GetFullName( locator->dataset_id, 0, NULL, status );
file_str = dat1GetFullName( locator->dataset_id, 1, NULL, status );
Expand All @@ -336,6 +336,7 @@ datMap(HDSLoc *locator, const char *type_str, const char *mode_str, int ndim,
printf("WILL TRY %s to mmap OFFSET=%zu %s:%s\n", reason, (size_t)offset, file_str, name_str);
}
MEM_FREE(name_str);
MEM_FREE(file_str);
}
#endif

Expand Down
20 changes: 14 additions & 6 deletions hdstrack2.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,34 +815,42 @@ void hds1ShowFiles( hdsbool_t listfiles, hdsbool_t listlocs, int * status ){
printf("Primary locators:\n");
loc = hdsFile->primhead;
while( loc ) {
namestr = NULL;
objid = dat1RetrieveIdentifier( loc, status );
if( objid > 0 ) {
namestr = dat1GetFullName( objid, 0, NULL, status );
} else {
namestr = "no groups/datasets";
}

printf(" %p [%s] (%s) group=%s\n", loc, namestr,
printf(" %p [%s] (%s) group=%s\n", loc,
(namestr ? namestr : "no groups/datasets"),
(loc->isprimary ? "primary" : "secondary"),
loc->grpname );

if (namestr) {
MEM_FREE( namestr );
}

loc = loc->prev;
}

printf("Secondary locators:\n");
loc = hdsFile->sechead;
while( loc ) {
namestr = NULL;
objid = dat1RetrieveIdentifier( loc, status );
if( objid > 0 ) {
namestr = dat1GetFullName( objid, 0, NULL, status );
} else {
namestr = "no groups/datasets";
}

printf(" %p [%s] (%s) group=%s\n", loc, namestr,
printf(" %p [%s] (%s) group=%s\n", loc,
(namestr ? namestr : "no groups/datasets"),
(loc->isprimary ? "primary" : "secondary"),
loc->grpname );

if (namestr) {
MEM_FREE( namestr );
}

loc = loc->prev;
}
}
Expand Down

0 comments on commit 233ac3c

Please sign in to comment.