Skip to content

Index out of bounds on FeatureManager.GetFeatureNames when flags array is empty #39

@esotuvaka

Description

@esotuvaka

This code:

func (fm *FeatureManager) GetFeatureNames() []string {
	flags, err := fm.featureProvider.GetFeatureFlags()
	if err != nil {
		log.Printf("failed to get feature flag names: %v", err)
		return nil
	}

	res := make([]string, 0, len(flags))
	for i, flag := range flags {
		res[i] = flag.ID
	}

	return res
}

Will index OOB if flags returns an empty []string. This causes a panic in client code that calls into this SDK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions