Loading...
--- libmalloc/libmalloc-521.100.59/src/malloc_common.c
+++ libmalloc/libmalloc-715.120.13/src/malloc_common.c
@@ -162,3 +162,65 @@
 {
 	return 0;
 }
+
+
+MALLOC_NOEXPORT MALLOC_NOINLINE
+void
+___BUG_IN_CLIENT_OF_LIBMALLOC_POINTER_BEING_FREED_WAS_NOT_ALLOCATED(
+		int flags, void *__unsafe_indexable ptr)
+{
+
+	malloc_report(flags, "*** error for object %p: "
+		"pointer being freed was not allocated\n", ptr);
+}
+
+#if !MALLOC_TARGET_EXCLAVES && !MALLOC_TARGET_EXCLAVES_INTROSPECTOR
+
+#if CONFIG_CHECK_PLATFORM_BINARY
+// Avoid conditioning on this if at all possible
+bool malloc_is_platform_binary = true;
+#endif // CONFIG_CHECK_PLATFORM_BINARY
+
+// Use malloc_is_platform_binary instead
+bool
+_malloc_is_platform_binary(void)
+{
+	uint32_t flags = 0;
+	int err = csops(getpid(), CS_OPS_STATUS, &flags, sizeof(flags));
+	if (err) {
+		return false;
+	}
+	return (flags & CS_PLATFORM_BINARY);
+}
+
+bool malloc_internal_security_policy = false;
+
+bool
+_malloc_allow_internal_security_policy(const char *envp[])
+{
+#if !TARGET_OS_SIMULATOR && defined(_COMM_PAGE_DEV_FIRM)
+	if (!*((uint32_t *)_COMM_PAGE_DEV_FIRM)) {
+		return false;
+	}
+#endif
+
+#if CONFIG_FEATUREFLAGS_SIMPLE
+	if (os_feature_enabled_simple(libmalloc, AllowInternalSecurityPolicy,
+			false)) {
+		return true;
+	}
+#endif
+
+	const char *flag = _simple_getenv(envp, "MallocAllowInternalSecurity");
+	if (flag) {
+		const char *endp;
+		long value = malloc_common_convert_to_long(flag, &endp);
+		if (!*endp && endp != flag && (value == 0 || value == 1)) {
+			return (bool)value;
+		}
+	}
+
+	return false;
+}
+
+#endif // !MALLOC_TARGET_EXCLAVES && !MALLOC_TARGET_EXCLAVES_INTROSPECTOR