Bug when Type = ellipse and Style is over 105
mjbertrand at GMAIL.COM
Sat Nov 12 09:35:29 EST 2005
just to follow my tought of yesterday, here is the code to dynamically
allocate space to the array:
for(z=0; z<symbol->stylelength; z++)
numElemStyle = numElemStyle + symbol->style[z];
styleDashed = (int *)calloc(numElemStyle, sizeof(int));
It could be put immediately after "symbol =
&(symbolset->symbol[style->symbol]);" (around line 1620) in mapgd.c
Also, don't forget to put a "free(styleDashed);" before each return in
the function. (To prevent memory leak)
Any comment will be welcome.
I'm receiving message from MAPSERVER-DEV often a long time after they
were posted. Is there any reason to that ? (Example : I didn't yet
receive the message I post yesterday afternoon)
On 11/11/05, Mathieu Bertrand <mjbertrand at gmail.com> wrote:
> I have a mapfile declaring a symbol like this one :
> NAME 'test'
> TYPE ELLIPSE
> POINTS 1 1 END
> FILLED true
> 50 56
> With that symbol, mapserver always crash.
> However, if I set the following STYLE, it don't crash :
> 50 55
> I scan through the code and the error come from mapgd.c, in the
> function "msDrawLineSymbolGD". Nearly at the end of the function,
> there is the following code :
> int k=0, sc;
> sc = fc; /* start with foreground color */
> for(i=0; i<symbol->stylelength; i++)
> for(j=0; j<symbol->style[i]; j++)
> styleDashed[k] = sc;
> if(sc==fc) sc = bc;
> else sc = fc;
> (format may differ)
> Problem is because styleDashed is declare : "int styleDashed;"
> I don't know why it work for k = 105 (style 50 55) when the array is
> declare to be 100 elements, but it crash when k = 106.
> I declared the array to 200 elements and mapserver didn't crash.
> Is anybody know why that array was declared to be only 100 elements.
> I'm not a pro in c programming, but I'm pretty sure that there is a
> way to allocate space in the array dynamically depending on the style
> declaration of the mapfile with malloc. Is there any reason why it
> was not implemented with malloc at the beggining ?
> Thank you,
> -Mathieu Bertrand
More information about the mapserver-dev