shithub: libmujs

Download patch

ref: b005928523d2427f8b1daac093c259ab53dba3e9
parent: c1edf5862950a53253bc0946b9af64ae36d477c5
author: Tor Andersson <tor.andersson@artifex.com>
date: Mon Jan 5 14:59:00 EST 2015

Add paranoid asserts to check js_Value struct layout and alignment.

--- a/jsstate.c
+++ b/jsstate.c
@@ -5,6 +5,8 @@
 #include "jsrun.h"
 #include "jsbuiltin.h"
 
+#include <assert.h>
+
 static void *js_defaultalloc(void *actx, void *ptr, unsigned int size)
 {
 	if (size == 0) {
@@ -176,6 +178,9 @@
 js_State *js_newstate(js_Alloc alloc, void *actx)
 {
 	js_State *J;
+
+	assert(sizeof(js_Value) == 16);
+	assert(offsetof(js_Value, type) == 15);
 
 	if (!alloc)
 		alloc = js_defaultalloc;