diff --git a/src/modules/Image/encodings/gif.c b/src/modules/Image/encodings/gif.c
index 572e20a57da2de1b9fabfa0176877e4056234706..1125e80284aacb09227e019f75fff7dd13ddd0fe 100644
--- a/src/modules/Image/encodings/gif.c
+++ b/src/modules/Image/encodings/gif.c
@@ -1,9 +1,9 @@
-/* $Id: gif.c,v 1.39 1998/04/16 22:54:03 mirar Exp $ */
+/* $Id: gif.c,v 1.40 1998/04/16 23:34:15 mirar Exp $ */
 
 /*
 **! module Image
 **! note
-**!	$Id: gif.c,v 1.39 1998/04/16 22:54:03 mirar Exp $
+**!	$Id: gif.c,v 1.40 1998/04/16 23:34:15 mirar Exp $
 **! submodule GIF
 **!
 **!	This submodule keep the GIF encode/decode capabilities
@@ -31,7 +31,7 @@
 #include <ctype.h>
 
 #include "stralloc.h"
-RCSID("$Id: gif.c,v 1.39 1998/04/16 22:54:03 mirar Exp $");
+RCSID("$Id: gif.c,v 1.40 1998/04/16 23:34:15 mirar Exp $");
 #include "pike_macros.h"
 #include "object.h"
 #include "constants.h"
@@ -1809,13 +1809,11 @@ static void image_gif__decode(INT32 args)
       error("Image.GIF._decode: internal error: "
 	    "illegal result from __decode\n");
    
-   (a=sp[-1].u.array)->refs++;
+   a=sp[-1].u.array;
    if (a->size<5)
       error("Image.GIF._decode: given (__decode'd) array "
 	    "is too small\n");
 
-   pop_n_elems(1);
-
    push_svalue(a->item+0); /* xsize */
    push_svalue(a->item+1); /* ysize */
 
@@ -1978,6 +1976,8 @@ static void image_gif__decode(INT32 args)
 	 }
 
    f_aggregate(n);
+   stack_swap();
+   pop_stack();
 }
 
 /*