Merge pull request #2646 from ZhipengXue97/next

Fix potential null dereference
This commit is contained in:
Ward Fisher 2023-08-01 14:00:30 -06:00 committed by GitHub
commit 2cd9d2674a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1156,6 +1156,15 @@ aws_load_credentials(NCglobalstate* gstate)
if((stat = awsparse(text,profiles))) goto done;
}
}
/* add a "none" credentials */
{
struct AWSprofile* noprof = (struct AWSprofile*)calloc(1,sizeof(struct AWSprofile));
if(noprof == NULL) {stat = NC_ENOMEM; goto done;}
noprof->name = strdup("none");
noprof->entries = nclistnew();
nclistpush(profiles,noprof); noprof = NULL;
}
if(gstate->rcinfo->s3profiles)
freeprofilelist(gstate->rcinfo->s3profiles);