summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-06-26 02:17:49 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-07-03 01:38:12 +0200
commitf84c3ceb0447477eb022cd5da6c8f27a705deae6 (patch)
tree1bf12f75f7ff37e7b7056672c4a2dc115a6bcaed /sysdeps
parent4b5e576fc21931969c0a1b53fdaf7ce3bfcebb86 (diff)
downloadglibc-f84c3ceb0447477eb022cd5da6c8f27a705deae6.tar.gz
glibc-f84c3ceb0447477eb022cd5da6c8f27a705deae6.tar.xz
glibc-f84c3ceb0447477eb022cd5da6c8f27a705deae6.zip
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>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/readdir64.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sysdeps/mach/hurd/readdir64.c b/sysdeps/mach/hurd/readdir64.c
index 2c01ca22c9..2d946793af 100644
--- a/sysdeps/mach/hurd/readdir64.c
+++ b/sysdeps/mach/hurd/readdir64.c
@@ -64,9 +64,13 @@ __readdir64 (DIR *dirp)
 	      /* The data was passed out of line, so our old buffer is no
 		 longer useful.  Deallocate the old buffer and reset our
 		 information for the new buffer.  */
-	      __vm_deallocate (__mach_task_self (),
-			       (vm_address_t) dirp->__data,
-			       dirp->__allocation);
+	      if (dirp->__data != NULL)
+		{
+		  err = __vm_deallocate (__mach_task_self (),
+					 (vm_address_t) dirp->__data,
+					 dirp->__allocation);
+		  assert_perror (err);
+		}
 	      dirp->__data = data;
 	      dirp->__allocation = round_page (dirp->__size);
 	    }