Check if src_addr is possible to free

This commit is contained in:
MasaGratoR 2023-04-03 01:31:40 +02:00 committed by GitHub
parent dca4fb772a
commit 2c756d1435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,6 +114,21 @@ Result tmemClose(TransferMemory* t)
}
if (t->src_addr != NULL) {
if ((t->perm & Perm_Rw) != Perm_Rw) {
MemoryInfo m = {0};
u32 p = 0;
rc = svcQueryMemory(&m, &p, (u64)(t->src_addr));
if (R_FAILED(rc)) {
return rc;
}
while ((m.perm & Perm_Rw) != Perm_Rw) {
rc = svcQueryMemory(&m, &p, (u64)(t->src_addr));
if (R_FAILED(rc)) {
return rc;
}
svcSleepThread(100000);
}
}
__libnx_free(t->src_addr);
}