Skip to content

Commit 35e33ea

Browse files
authored
Fix a memory leak while changing permissions (#259)
1 parent b1720ed commit 35e33ea

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

pkgs/io_file/test/remove_directory_tree_test.dart

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,24 @@ void main() {
192192
io.Directory('$path/subdir1/subdir2').createSync(recursive: true);
193193
io.File('$path/subdir1/subdir2/file1').writeAsStringSync('Hello World');
194194
// r-xr-x---
195-
if (libc.chmod('$path/subdir1/subdir2'.toNativeUtf8().cast(), 360) ==
196-
-1) {
197-
assert(libc.errno == 0);
198-
}
195+
using((arena) {
196+
if (libc.chmod(
197+
'$path/subdir1/subdir2'.toNativeUtf8(allocator: arena).cast(),
198+
360,
199+
) ==
200+
-1) {
201+
assert(libc.errno == 0);
202+
}
203+
});
204+
199205
addTearDown(
200206
// rwxrwxrwx
201-
() => libc.chmod('$path/subdir1/subdir2'.toNativeUtf8().cast(), 511),
207+
() => using(
208+
(arena) => libc.chmod(
209+
'$path/subdir1/subdir2'.toNativeUtf8(allocator: arena).cast(),
210+
511,
211+
),
212+
),
202213
);
203214

204215
expect(

0 commit comments

Comments
 (0)