hurd: Fix calling vm_deallocate (NULL)

Only call vm_deallocate when we do have the old buffer, and check for
unexpected errors.

Spotted while debugging a msgids/readdir issue on x86_64-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230625231751.404120-3-bugaevc@gmail.com>
This commit is contained in:
Sergey Bugaev 2023-06-26 02:17:49 +03:00 committed by Samuel Thibault
parent 4b5e576fc2
commit f84c3ceb04
1 changed files with 7 additions and 3 deletions

View File

@ -64,9 +64,13 @@ __readdir64 (DIR *dirp)
/* The data was passed out of line, so our old buffer is no /* The data was passed out of line, so our old buffer is no
longer useful. Deallocate the old buffer and reset our longer useful. Deallocate the old buffer and reset our
information for the new buffer. */ information for the new buffer. */
__vm_deallocate (__mach_task_self (), if (dirp->__data != NULL)
(vm_address_t) dirp->__data, {
dirp->__allocation); err = __vm_deallocate (__mach_task_self (),
(vm_address_t) dirp->__data,
dirp->__allocation);
assert_perror (err);
}
dirp->__data = data; dirp->__data = data;
dirp->__allocation = round_page (dirp->__size); dirp->__allocation = round_page (dirp->__size);
} }