Re: AfxIsValidAddress equivalent, test valid memory
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=tX57vxuSt94PWVokSTCmctu3QD1GoQ6Bj4Aulr0cwgE9+6qVtssqd+jYbVmowq6O8dNbz3lySKaPiRslcOUR+vEXRXbrf7lSsITU0AMyWvYWFAD6teRRO3gwt6bM/oxRU0tgBZWa2sBboVo1FfJUp+SklSzvU7Z9kY8KtSbuhQA= ; Oops, forgot to free the malloc'ed memory (never did that before:-) -brendan Boolean memIsValid(vm_address_t m_addr, size_t numOfBytes) { vm_address_t dstPtr = (vm_address_t)malloc(numOfBytes); mach_port_t thisTask = mach_task_self(); vm_size_t sizeRead = numOfBytes; int err; err = vm_read_overwrite(thisTask, m_addr, numOfBytes, dstPtr, &sizeRead); if (err == noErr && sizeRead != numOfBytes) err = -1; free ((void*)dstPtr); // !! return (err == noErr); } _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Brendan Creane