From 2b7f9244e08947b277015bb681dfa616aadce3b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 20 Aug 2014 17:33:24 +0200
Subject: [PATCH] encode_value: Don't regard the variant dispatcher as a CFUN.

The variant dispatcher is a CFUN that may show up in pure Pike
programs, so don't fallback to the C-program encodings when
the only CFUN is the variant dispatcher.

Potentially fixes dumping problems with Crypto.RSA.State
(where generate_key() is a variant function).
---
 src/encode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/encode.c b/src/encode.c
index 4f61d6dc6f..4d1b31040d 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -1011,7 +1011,9 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc
 	{
 	  int has_local_c_methods = 0;
 	  for (d = 0; d < p->num_identifiers; d++) {
-	    if (IDENTIFIER_IS_C_FUNCTION(p->identifiers[d].identifier_flags)) {
+	    struct identifier *id = p->identifiers + d;
+	    if (IDENTIFIER_IS_C_FUNCTION(id->identifier_flags) &&
+		!low_is_variant_dispatcher(id)) {
 	      has_local_c_methods = 1;
 	      break;
 	    }
-- 
GitLab