Skip to content

Commit 7de1f52

Browse files
authored
fix: null pointer exception (#2457)
* fix: nil ptr * fix: nil ptr
1 parent 7473fe7 commit 7de1f52

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changelog/2457.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
tencentcloud_clb_redirection: Fix null pointer exception
3+
```

tencentcloud/services/clb/resource_tc_clb_redirection.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ func resourceTencentCloudClbRedirectionCreate(d *schema.ResourceData, meta inter
136136
if e != nil {
137137
return tccommon.RetryError(e)
138138
}
139+
140+
if instance == nil {
141+
return resource.NonRetryableError(fmt.Errorf("[CLB redirection][Create] the queried instance is empty [DescribeListenerById]"))
142+
}
143+
if instance.Protocol == nil || instance.Port == nil {
144+
return resource.NonRetryableError(fmt.Errorf("[CLB redirection][Create] protocol or port is nil, get protocol and port fail [DescribeListenerById]"))
145+
}
139146
protocol = *(instance.Protocol)
140147
port = int(*(instance.Port))
141148
return nil

0 commit comments

Comments
 (0)