<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40171 >
in freeciv version 2.1.3, gtk-2.0 client, in city report screen:
when I do "Select -> Cityzen Governor -> none" and there is at least one city
with CMA active, then the client crashes on a failed assertion:
civclient: cma_fec.c:178: cmafec_preset_get_parameter: Assertion `index >= 0
&& index < cmafec_preset_num()' failed.
This is because cmafec_preset_get_parameter gets CMA_NONE as an argument.
It can be fixed by testing idx != CMA_NONE before calling
cmafec_preset_get_parameter. It is correct because if the city is
CMA-controlled (controlled !=0) and we are selecting non-controlled cities
(idx == CMA_NONE), then we shouldn't select the city under consideration
(select = FALSE).
I attach a log of gdb session (gdb.log) which shows the problem and a fix
(fix-client-CMA-select-none.diff).
Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb729c940 (LWP 12131)]
0xb7f88410 in __kernel_vsyscall ()
(gdb) bt
#0 0xb7f88410 in __kernel_vsyscall ()
#1 0xb759df15 in raise () from /lib/i686/cmov/libc.so.6
#2 0xb759f891 in abort () from /lib/i686/cmov/libc.so.6
#3 0xb75970ee in __assert_fail () from /lib/i686/cmov/libc.so.6
#4 0x080fa0fb in cmafec_preset_get_parameter (index=10000) at cma_fec.c:178
#5 0x081046d5 in select_cma_callback (w=0x9082258, data=0x2710)
at cityrep.c:508
#6 0xb78de9bf in g_cclosure_marshal_VOID__VOID ()
from /usr/lib/libgobject-2.0.so.0
#7 0xb78d16f9 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#8 0xb78e5c3d in ?? () from /usr/lib/libgobject-2.0.so.0
#9 0x096ae7b0 in ?? ()
#10 0x00000000 in ?? ()
(gdb) fr 4
#4 0x080fa0fb in cmafec_preset_get_parameter (index=10000) at cma_fec.c:178
178 assert(index >= 0 && index < cmafec_preset_num());
(gdb) p index
$1 = 10000
(gdb) up
#5 0x081046d5 in select_cma_callback (w=0x9082258, data=0x2710)
at cityrep.c:508
508 } else if (idx >= 0 && controlled &&
(gdb) l
503 if (idx == CMA_CUSTOM && controlled
504 && cmafec_preset_get_index_of_parameter(¶meter) == -1) {
505 select = TRUE;
506 } else if (idx == CMA_NONE && !controlled) {
507 select = TRUE;
508 } else if (idx >= 0 && controlled &&
509 cm_are_parameter_equal(¶meter,
510 cmafec_preset_get_parameter(idx))) {
511 select = TRUE;
512 }
(gdb) p controlled
$2 = 0
(gdb) quit
--- client/gui-gtk-2.0/cityrep.c 2008-03-23 21:19:32.000000000 +0000
+++ client/gui-gtk-2.0/cityrep.c.orig 2008-01-23 11:18:53.000000000 +0000
@@ -505,7 +505,7 @@
select = TRUE;
} else if (idx == CMA_NONE && !controlled) {
select = TRUE;
- } else if (idx >= 0 && controlled && idx != CMA_NONE &&
+ } else if (idx >= 0 && controlled &&
cm_are_parameter_equal(¶meter,
cmafec_preset_get_parameter(idx))) {
select = TRUE;
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev