Skip to content

Unhandled case in equalStrings function implementation #1654

@a-hilaly

Description

@a-hilaly

The equalStrings function in most of (if not all) hooks.go files compares two string pointers and returns whether they are equal or not while taking into consideration that a nil pointer and an empty string are equal. However, there is a case that is not being handled correctly in the current implementation. As a result, the function may not return the expected result
Here is the implementation:

func equalStrings(a, b *string) bool {
	if a == nil {
		return b == nil || *b == ""
	}
	return (*a == "" && b == nil) || *a == *b
}

Again thank you @embano1 for spotting this!

Metadata

Metadata

Assignees

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release.service/allIndicates issues or PRs related to all the service controllers.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions