Skip to content

Possible handle leak in http_reader.go #4494

@Bbulatov

Description

@Bbulatov

Description

Hello!
During the static analysis was found possible mistake:

  1. The handle '(*net/http.Client).Do(hrs.client, req).Body' is created at http_reader.go:183 by calling function 'http.Client.Do' and lost at http_reader.go:193.
resp, err := hrs.client.Do(req)
	if err != nil {
		return nil, err
	}

	// Normally would use client.SuccessStatus, but that would be a cyclic
	// import
	if resp.StatusCode >= 200 && resp.StatusCode <= 399 {
		if hrs.readerOffset > 0 {
			if resp.StatusCode != http.StatusPartialContent {
				return nil, ErrWrongCodeForByteRange
			}

Reproduce

Possible execution function reader()

Expected behavior

Possible handle leak

registry version

v2.8.3

Additional Info

No response

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