From: Roman Zippel <zippel@linux-m68k.org>
Date: Mon, 18 Sep 2006 01:05:02 +0200
Subject: Change the ruby 'digest' typemaps to tolerate NULL pointers.

Bug #387996: I looked at the failing self tests [on m68k]. The first
one is a bug in the created wrapper. The basic problem is that in
svn_delta.c:_wrap_svn_txdelta_apply_wrapper() the value of temp3 is not
modified by svn_txdelta_apply_wrapper(), so the return is basically
random. In this case the stack is clear and svn_md5_digest_to_cstring()
returns a NULL, which rb_str_new2() doesn't like.

The easiest fix is to change the typemap in svn_types.swg so it can deal
with the NULL pointer. (BTW I tried returning Qnil here, but that
doesn't work well output_helper.)

Sent upstream: http://svn.haxx.se/dev/archive-2006-09/0536.shtml

--- a/subversion/bindings/swig/include/svn_types.swg
+++ b/subversion/bindings/swig/include/svn_types.swg
@@ -1096,7 +1096,7 @@
 #ifdef SWIGRUBY
 %typemap(argout) unsigned char digest[ANY] {
   char *digest_string = (char *)svn_md5_digest_to_cstring($1, _global_pool);
-  %append_output(rb_str_new2(digest_string));
+  %append_output(rb_str_new2(digest_string ? digest_string : ""));
 }
 #endif
 
