diff --git a/src/encode.c b/src/encode.c
index 6003aaa35ccf3a3a5c3aa61d1df9b5eeb9b772e2..ad35247f5e767ad51c09a5ac82c6fb8ae8428923 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: encode.c,v 1.289 2009/08/17 11:42:15 grubba Exp $
+|| $Id: encode.c,v 1.290 2009/08/17 13:55:06 grubba Exp $
 */
 
 #include "global.h"
@@ -3987,8 +3987,9 @@ static void decode_value2(struct decode_data *data)
 	      Pike_error("Failed to decode program. (string too short)\n");
 	    }
 	    low_add_many_to_program(Pike_compiler,
-				    (PIKE_OPCODE_T *)data->data + data->ptr,
+				    (PIKE_OPCODE_T *)(data->data + data->ptr),
 				    local_num_program);
+	    data->ptr += local_num_program * sizeof(PIKE_OPCODE_T);
 
 	    /* Decode relocations */
 	    for (e=0; e<(int)local_num_relocations; e++) {