Skip to content

Commit

Permalink
azuread_group - Fix crash and memory leak (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfrahry authored Oct 4, 2024
1 parent 126105c commit 9eea5d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions internal/services/groups/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in
}

// No point in retrying if the caller wasn't specified as an owner
if len(ownersWithoutCallingPrincipal) == len(*properties.Owners) {
if len(ownersWithoutCallingPrincipal) == len(pointer.From(properties.Owners)) {
log.Printf("[DEBUG] Not retrying group creation for %q as owner was not specified", displayName)
return tf.ErrorDiagF(err, "Creating group %q", displayName)
}
Expand Down Expand Up @@ -1095,7 +1095,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in
}

existingMembers := make([]string, 0)
for resp.Model != nil {
if resp.Model != nil {
for _, m := range *resp.Model {
existingMembers = append(existingMembers, pointer.From(m.DirectoryObject().Id))
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@ func groupResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta in
}

existingOwners := make([]string, 0)
for resp.Model != nil {
if resp.Model != nil {
for _, o := range *resp.Model {
existingOwners = append(existingOwners, pointer.From(o.DirectoryObject().Id))
}
Expand Down
8 changes: 4 additions & 4 deletions internal/services/groups/group_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ resource "azuread_application" "test" {
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
client_id = azuread_application.test.client_id
}
resource "azuread_group" "test" {
Expand Down Expand Up @@ -917,7 +917,7 @@ resource "azuread_application" "test" {
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
client_id = azuread_application.test.client_id
}
resource "azuread_group" "test" {
Expand Down Expand Up @@ -1020,8 +1020,8 @@ resource "azuread_application" "test" {
}
resource "azuread_service_principal" "test" {
count = 27
application_id = azuread_application.test[count.index].application_id
count = 27
client_id = azuread_application.test[count.index].client_id
}
resource "azuread_user" "test" {
Expand Down

0 comments on commit 9eea5d7

Please sign in to comment.