buffer_copy: Assertion `dest' failed when parsing UMN mapfile
Calling
/usr/lib/cgi-bin/tinyows -check
with TINYOWS_MAPFILE set gives the following exit error message:
tinyows: src/struct/buffer.c:348: buffer_copy: Assertion `dest' failed.
It happens with any map file including the example from http://mapserver.org/tinyows/mapfileconfig.html
Version 1.1.0 on Ubuntu 12.04 from UbuntuGIS and master branch compiled on the same machine.
Backtrace:
#0 0x00007ffff72bb425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff72beb8b in __GI_abort () at abort.c:91
#2 0x00007ffff72b40ee in __assert_fail_base (fmt=<optimized out>, assertion=0x42a1ab "dest",
file=0x42a16d "src/struct/buffer.c", line=<optimized out>, function=<optimized out>) at assert.c:94
#3 0x00007ffff72b4192 in __GI___assert_fail (assertion=0x42a1ab "dest", file=0x42a16d "src/struct/buffer.c", line=348,
function=0x42a400 "buffer_copy") at assert.c:103
#4 0x0000000000415d34 in buffer_copy (dest=<optimized out>, src=<optimized out>) at src/struct/buffer.c:348
#5 buffer_copy (dest=<optimized out>, src=<optimized out>) at src/struct/buffer.c:346
#6 0x000000000040a951 in end_layer () at src/mapfile/mapfile.l:542
#7 yylex () at src/mapfile/mapfile.l:614
#8 0x000000000040b6d5 in ows_parse_config_mapfile (o=0x634040, filename=<optimized out>) at src/mapfile/mapfile.l:789
#9 0x000000000040c848 in ows_parse_config (o=0x634040, filename=<optimized out>) at src/ows/ows_config.c:706
#10 0x0000000000402ba1 in main (argc=2, argv=0x7fffffffde78) at src/ows/ows.c:360
The following changes fix the crash:
diff --git a/src/mapfile/mapfile.l b/src/mapfile/mapfile.l
index 36066e9..474a4d7 100644
--- a/src/mapfile/mapfile.l
+++ b/src/mapfile/mapfile.l
@@ -539,12 +539,14 @@ static void end_layer()
buffer_add_str(map_l->storage->schema, "public");
if (!map_is_dump) map_l->retrievable=map_l->writable = false;
+ map_l->name_prefix = buffer_init();
buffer_copy(map_l->name_prefix, map_l->name);
if (map_l->ns_prefix->use) {
buffer_add_head(map_l->name_prefix, ':');
buffer_add_head_str(map_l->name_prefix, map_l->ns_prefix->buf);
}
+ map_l->name_no_uri = buffer_init();
buffer_copy(map_l->name_no_uri, map_l->name);
if (map_l->ns_uri->use) {
Thank you for the fix, but it should be in mapfile.c instead of mapfile.l
The issue has been patched in UbuntuGIS thanks to you fix.
EDIT: @pka is right, removed my patch
Hi Jérôme, mapfile.c is generated from mapfile.l with flex. The step has to be done manually, because it's missing in the Makefile. Pirmin
Ah, sorry about that, it makes more sense now thank you.
Is this supposed to be fixed now? I do have this problem tinyows: src/struct/buffer.c:348: buffer_copy: Assertion `dest' failed. when running tunyows -check using a mapfile.
The code above is different of what I have in mapfile.l