diff --git a/src/modules/image/font.c b/src/modules/image/font.c
index fe28d216cc9dcfd71273bb0ac1f856884b485df5..0a6ef94774199edb576a7294d8de80cc04d2e195 100644
--- a/src/modules/image/font.c
+++ b/src/modules/image/font.c
@@ -1,4 +1,4 @@
-/* $Id: font.c,v 1.8 1996/11/22 20:28:15 law Exp $ */
+/* $Id: font.c,v 1.9 1996/11/23 04:26:13 law Exp $ */
 
 #include "global.h"
 
@@ -231,11 +231,25 @@ void font_load(INT32 args)
 
 		  for (i=0; i<THIS->chars; i++)
 		  {
-		     ch=(struct char_head*)
-			((char *)(THIS->mem)+ntohl(fh->o[i]));
-		     THIS->charinfo[i].width = ntohl(ch->width);
-		     THIS->charinfo[i].spacing = ntohl(ch->spacing);
-		     THIS->charinfo[i].pixels = ch->data;
+		     if (i*sizeof(INT32)<(unsigned long)size
+			 && ntohl(fh->o[i])<(unsigned long)size
+			 && ! ( ntohl(fh->o[i]) % 4) ) /* must be aligned */
+		     {
+			ch=(struct char_head*)
+			   ((char *)(THIS->mem)+ntohl(fh->o[i]));
+			THIS->charinfo[i].width = ntohl(ch->width);
+			THIS->charinfo[i].spacing = ntohl(ch->spacing);
+			THIS->charinfo[i].pixels = ch->data;
+		     }
+		     else /* illegal <tm> offset or illegal align */
+		     {
+			free_font_struct(new);
+			THIS=NULL;
+			pop_n_elems(args);
+			push_int(0);
+			return;
+		     }
+
 		  }
 
 		  close(fd);
diff --git a/src/modules/image/togif.c b/src/modules/image/togif.c
index 1f1c1ed49b3eabbaeccbd1ced5facba1d2088bc6..970b880b332e03b8a8925c846ea6e4f34fbe9913 100644
--- a/src/modules/image/togif.c
+++ b/src/modules/image/togif.c
@@ -1,4 +1,4 @@
-/* $Id: togif.c,v 1.13 1996/11/22 20:28:19 law Exp $ */
+/* $Id: togif.c,v 1.14 1996/11/23 04:26:16 law Exp $ */
 /*
 
 togif 
@@ -460,6 +460,8 @@ void image_togif(INT32 args)
 
    if (args>0 && sp[-args].type==T_ARRAY)
       ct=colortable_from_array(sp[-args].u.array,"image->togif()\n");
+   else if (args>0 && args!=3 && sp[-args].type==T_INT)
+      ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer)));
 
    if (args>=3+!!ct)
    {
@@ -483,6 +485,8 @@ void image_togif_fs(INT32 args)
 
    if (args>0 && sp[-args].type==T_ARRAY)
       ct=colortable_from_array(sp[-args].u.array,"image->togif()\n");
+   else if (args>0 && args!=3 && sp[-args].type==T_INT)
+      ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer)));
 
    if (args>=3+!!ct)
    {
@@ -569,8 +573,11 @@ CHRONO("gif add init");
       y=sp[1-args].u.integer;
    }
 
-   if (args>2 && sp[2-args].type==T_ARRAY)
-      ct=colortable_from_array(sp[2-args].u.array,"image->gif_add()\n");
+
+   if (args>0 && sp[-args].type==T_ARRAY)
+      ct=colortable_from_array(sp[-args].u.array,"image->gif_add()\n");
+   else if (args!=3 && sp[-args].type==T_INT)
+      ct=colortable_quant(THIS,max(256,min(2,sp[-args].u.integer)));
 
    if (args>2+!!ct)
    {