Skip to content

[SR-6449] FileManager.removeItem(atPath) leaks #4050

@swift-ci

Description

@swift-ci
Previous ID SR-6449
Radar None
Original Reporter oc243 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Leak
Assignee @spevans
Priority Medium

md5: ed00226ba5251454be00fae148b361f3

Issue Description:

FileManager.removeItem(atPath: ) leaks when removing a non-empty directory, as shown in this repro:

func removeItem() throws -> () {
    let fm = FileManager()
    while true {
        let _ = try fm.createDirectory(atPath: "/tmp/foo", withIntermediateDirectories: true, attributes: [:])
        let _ = fm.createFile(atPath: "/tmp/foo/bar", contents: nil)
        try fm.removeItem(atPath: "/tmp/foo/")
    }
}

Looks like the issue is that Foundation.FileManager.fileSystemRepresentation returns a C-string that is not free'd in the caller (and can't be free'd by an autorelease pool on Linux).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions