Attached are a couple of patches:
Changelog:
2001-04-04 Matt Hargett <[EMAIL PROTECTED]>
* vm.c: Added NULL pointer checks on pointers passed into
interfaces. Initialized new pointers to NULL.
* resource.h: Changed sciprintf to be void to be consistent
with documentation.
* console.c: Ditto.
--
http://www.clock.org/~matt
-- Attached file included as plaintext by Listar --
-- File: vm.c-20010401-patch
--- vm.c.orig Mon Apr 2 23:09:42 2001
+++ vm.c Mon Apr 2 23:57:28 2001
@@ -63,6 +63,12 @@ script_error(state_t *s, char *file, int
inline void putInt16(byte *addr, word value)
{
+ if (NULL == addr)
+ {
+ sciprintf("vm.c: putInt16(): NULL passed for \"addr\"\n");
+ return;
+ }
+
addr[0] = value &0xff;
addr[1] = value >> 8;
}
@@ -70,6 +76,12 @@ inline void putInt16(byte *addr, word va
inline heap_ptr
get_class_address(state_t *s, int classnr)
{
+ if (NULL == s)
+ {
+ sciprintf("vm.c: get_class_address(): NULL passed for \"s\"\n");
+ return;
+ }
+
if (!s->classtable[classnr].scriptposp) {
sciprintf("Attempt to dereference class %x, which doesn't exist\n", classnr);
script_error_flag = script_debug_flag = 1;
@@ -182,6 +194,12 @@ send_selector(state_t *s, heap_ptr send_
/* send_obj and work_obj are equal for anything but 'super' */
/* Returns a pointer to the TOS exec_stack element */
{
+ if (NULL == s)
+ {
+ sciprintf("vm.c: exec_stack_t(): NULL passed for \"s\"\n");
+ return NULL;
+ }
+
heap_ptr lookupresult;
int selector;
int argc;
@@ -388,7 +406,13 @@ add_exec_stack_entry(state_t *s, heap_pt
int selector, heap_ptr sendp, int origin, int localvarp)
/* Returns new TOS element */
{
- exec_stack_t *xstack;
+ exec_stack_t *xstack = NULL;
+
+ if (NULL == s)
+ {
+ sciprintf("vm.c: add_exec_stack_entry(): NULL passed for \"s\"\n");
+ return NULL;
+ }
if (!s->execution_stack)
s->execution_stack = malloc(sizeof(exec_stack_t) * (s->execution_stack_size =
16));
@@ -441,7 +465,13 @@ run_vm(state_t *s, int restoring)
guint16 utemp, utemp2;
gint16 opparams[4]; /* opcode parameters */
-
+
+ if (NULL == s)
+ {
+ sciprintf("vm.c: run_vm(): NULL passed for \"s\"\n");
+ return;
+ }
+
int restadjust = s->amp_rest; /* &rest adjusts the parameter count by this value */
/* Current execution data: */
exec_stack_t *xs = s->execution_stack + s->execution_stack_pos;
@@ -1220,6 +1250,12 @@ script_instantiate(state_t *s, int scrip
if (!script) {
sciprintf("Script 0x%x requested but not found\n", script_nr);
/* script_debug_flag = script_error_flag = 1; */
+ return 0;
+ }
+
+ if (NULL == s)
+ {
+ sciprintf("vm.c: script_instantiate(): NULL passed for \"s\"\n");
return 0;
}
-- Attached file included as plaintext by Listar --
-- File: resource.h-20010401-patch
--- resource.h.orig Mon Apr 2 23:04:59 2001
+++ resource.h Mon Apr 2 23:22:49 2001
@@ -235,7 +235,7 @@ sci_finish_find(sci_dir_t *dirent);
** the second operation is guaranteed to be a no-op.
*/
-int
+void
sciprintf(char *fmt, ...);
#define gfxprintf sciprintf
/* Prints a string to the console stack
-- Attached file included as plaintext by Listar --
-- File: console.c-20010401-patch
--- console.c.orig Mon Apr 2 23:44:58 2001
+++ console.c Mon Apr 2 23:51:15 2001
@@ -385,7 +385,7 @@ con_hook_int(int *pointer, char *name, c
/****************************************/
-int
+void
sciprintf(char *fmt, ...)
{
va_list argp;
@@ -453,7 +453,7 @@ sciprintf(char *fmt, ...)
con_outputlookback = con_outputbufpos;
free(buf);
- return 0;
+ return;
}