Unicode 3.2.0 normalization tests makes Unicode module dump core.

Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=3027

Reported by Martin Nilsson, IDA nilsson@pike.ida.liu.se

Running the test file test.pike in the Unicode directory, with the provided patches, creates a segmentation fault.

RCS file: /cvs/Pike/7.3/src/post_modules/Unicode/test.pike,v
retrieving revision 1.2
diff -u -r1.2 test.pike
--- test.pike   2001/06/28 20:02:58     1.2
+++ test.pike   2002/04/19 02:16:53
@@ -1,4 +1,4 @@
-#define FILE "NormalizationTest-3.1.0.txt"
+#define FILE "NormalizationTest.txt"

 #define c1 c[0]
 #define c2 c[1]
@@ -10,11 +10,11 @@
 {
   int tests, fail, part, opl;
   write("Performing Unicode normalization tests\n");
-  write("See http://www.unicode.org/Public/3.1-Update/" FILE "\n" );
+  write("See
http://www.unicode.org/Public/3.2-Update/NormalizationTest-3.2.0.txt\n" );

   foreach( Stdio.File( argv[1]+"/"+FILE,"r" )->read()/"\n", string l )
   {
-    if( !strlen( l ) )
+    if( !strlen( l ) || l[0] == '#' )
       continue;

Crash data from gdb:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 28321)]
uc_buffer_insert (b=0x82eb4f8, pos=0, c=1457) at
/home/nilsson/Pike/7.3/src/post_modules/Unicode/buffer.c:114
114           b->data[i] = b->data[i-1];
(gdb) bt
#0  uc_buffer_insert (b=0x82eb4f8, pos=0, c=1457) at
/home/nilsson/Pike/7.3/src/post_modules/Unicode/buffer.c:114
#1  0x4037cc5e in unicode_decompose_buffer (source=0x82eb4e0, how=1)
    at /home/nilsson/Pike/7.3/src/post_modules/Unicode/normalize.c:231
#2  0x4037ce00 in unicode_normalize (source=0x82eb240, how=2) at
/home/nilsson/Pike/7.3/src/post_modules/Unicode/normalize.c:288
#3  0x4037c4d4 in f_normalize (args=2) at
/home/nilsson/Pike/7.3/src/post_modules/Unicode/unicode_module.cmod:141
#4  0x080713de in low_mega_apply (type=APPLY_SVALUE, args=2,
arg1=0x8350b4c, arg2=0x0) at /home/nilsson/Pike/7.3/src/apply_low.h:187
#5  0x0806f570 in opcode_F_APPLY (arg1=4) at
/home/nilsson/Pike/7.3/src/interpret_functions.h:1830
#6  0x0834f743 in ?? ()
#7  0x080726b0 in mega_apply (type=APPLY_LOW, args=2, arg1=0x82c0738,
arg2=0x51) at /home/nilsson/Pike/7.3/src/interpret.c:1402
#8  0x08073197 in apply (o=0x82c0738, fun=0x81922d7 "_main", args=2) at
/home/nilsson/Pike/7.3/src/interpret.c:1703
#9  0x080c6bf1 in main (argc=4, argv=0xbffffa7c) at
/home/nilsson/Pike/7.3/src/main.c:716
#10 0x400c7316 in __libc_start_main (main=0x80c6260 <main>, argc=4,
ubp_av=0xbffffa7c, init=0x805f86c <_init>,
    fini=0x8172530 <_fini>, rtld_fini=0x4000d2fc <_dl_fini>,
stack_end=0xbffffa6c) at ../sysdeps/generic/libc-start.c:129
(gdb)