ObjFW  Check-in [ce1c7fe940]

Overview
Comment:OFObject: Use owner as a sentinel for pre_mem.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ce1c7fe94097c56f3087a3af51e2ba38dbe30a4b7ccab86356d71b881562c245
User & Date: js on 2012-03-21 14:47:14
Other Links: manifest | tags
Context
2012-03-21
15:39
OFThreadPool: Terminate threads on deallocation. check-in: 4ac1256458 user: js tags: trunk
14:47
OFObject: Use owner as a sentinel for pre_mem. check-in: ce1c7fe940 user: js tags: trunk
12:06
Make use of PACKAGE_VERSION. check-in: 7078674567 user: js tags: trunk
Changes

Modified src/OFObject.m from [0df01667b3] to [708e72ca3d].

65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
	struct pre_mem *firstMem, *lastMem;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
	of_spinlock_t retainCountSpinlock;
#endif
};

struct pre_mem {
	id owner;
	struct pre_mem *prev, *next;

};

#define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + \
	(__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1))
#define PRE_IVAR ((struct pre_ivar*)(void*)((char*)self - PRE_IVAR_ALIGN))

#define PRE_MEM_ALIGN ((sizeof(struct pre_mem) + \







<

>







65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
	struct pre_mem *firstMem, *lastMem;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
	of_spinlock_t retainCountSpinlock;
#endif
};

struct pre_mem {

	struct pre_mem *prev, *next;
	id owner;
};

#define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + \
	(__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1))
#define PRE_IVAR ((struct pre_ivar*)(void*)((char*)self - PRE_IVAR_ALIGN))

#define PRE_MEM_ALIGN ((sizeof(struct pre_mem) + \
984
985
986
987
988
989
990







991
992
993
994
995
996
997
			break;
	}

	iter = PRE_IVAR->firstMem;
	while (iter != NULL) {
		struct pre_mem *next = iter->next;








		free(iter);

		iter = next;
	}

	free((char*)self - PRE_IVAR_ALIGN);
}







>
>
>
>
>
>
>







984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
			break;
	}

	iter = PRE_IVAR->firstMem;
	while (iter != NULL) {
		struct pre_mem *next = iter->next;

		/*
		 * We can use owner as a sentinel to prevent exploitation in
		 * case there is a buffer underflow somewhere.
		 */
		if (iter->owner != self)
			abort();

		free(iter);

		iter = next;
	}

	free((char*)self - PRE_IVAR_ALIGN);
}