[Freeciv-Dev] (PR#10611) valgrind warning in is_valid_start_pos
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#10611) valgrind warning in is_valid_start_pos |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Mon, 18 Oct 2004 21:48:34 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10611 >
==29760== Invalid read of size 4
==29760== at 0x813C004: is_valid_start_pos (startpos.c:100)
==29760== by 0x80C5EBA: rand_map_pos_filtered (map.c:1610)
==29760== by 0x813CC37: create_start_positions (startpos.c:336)
==29760== by 0x8137441: map_fractal_generate (mapgen.c:1081)
==29760== Address 0x1BF177AC is 4 bytes before a block of size 124 alloc'd
==29760== at 0x1B906EDD: malloc (vg_replace_malloc.c:131)
==29760== by 0x804B512: fc_real_malloc (mem.c:79)
==29760== by 0x813C248: initialize_isle_data (startpos.c:150)
==29760== by 0x813C55F: create_start_positions (startpos.c:224)
This is my error, and easy to fix.
jason
? diff
? newtiles
? data/isotrident/selection.png
? data/isotrident/selection.spec
Index: server/generator/startpos.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/startpos.c,v
retrieving revision 1.4
diff -u -r1.4 startpos.c
--- server/generator/startpos.c 15 Oct 2004 09:39:06 -0000 1.4
+++ server/generator/startpos.c 19 Oct 2004 04:47:28 -0000
@@ -96,16 +96,16 @@
{
const struct start_filter_data *pdata = dataptr;
int i;
- struct islands_data_type *island
- = islands + islands_index[(int) map_get_continent(ptile)];
- int cont_size;
+ struct islands_data_type *island;
+ int cont_size, cont = map_get_continent(ptile);
/* Only start on certain terrain types. */
if (pdata->value[ptile->index] < pdata->min_value) {
return FALSE;
}
- if (islands[islands_index[(int) map_get_continent(ptile)]].starters == 0) {
+ assert(cont > 0);
+ if (islands[islands_index[cont]].starters == 0) {
return FALSE;
}
@@ -115,7 +115,8 @@
}
/* Don't start too close to someone else. */
- cont_size = get_continent_size(map_get_continent(ptile));
+ cont_size = get_continent_size(cont);
+ island = islands + islands_index[cont];
for (i = 0; i < pdata->count; i++) {
struct tile *tile1 = map.start_positions[i].tile;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#10611) valgrind warning in is_valid_start_pos,
Jason Short <=
|
|