Permalink
Browse files

msLayoutTextSymbol(): fix memory corruption in case of failed iconv() (

  • Loading branch information...
rouault committed Oct 24, 2014
1 parent 084be4d commit 5b2c46a24aef5d44c6d88add909d4d646fc10c15
Showing with 4 additions and 3 deletions.
  1. +4 −3 textlayout.c
View
@@ -435,7 +435,7 @@ int msLayoutTextSymbol(mapObj *map, textSymbolObj *ts, textPathObj *tgret) {
#endif
struct line_desc static_line_descs[STATIC_LINES];
int alloc_glyphs = 0;
- struct line_desc *line_descs;
+ struct line_desc *line_descs = NULL;
text_run *runs;
double oldpeny=3455,peny,penx=0; /*oldpeny is set to an unreasonable default initial value */
fontSetObj *fontset = NULL;
@@ -469,8 +469,6 @@ int msLayoutTextSymbol(mapObj *map, textSymbolObj *ts, textPathObj *tgret) {
while(len>0) {
iconv_status = iconv(cd, &inp, &len, &outp, &bufleft);
if(iconv_status == -1) {
- iconv_close(cd);
- free(encoded_text);
break;
}
}
@@ -486,6 +484,9 @@ int msLayoutTextSymbol(mapObj *map, textSymbolObj *ts, textPathObj *tgret) {
text_num_bytes = strlen(ts->annotext);
}
+ if( text_num_bytes == 0 )
+ return 0;
+
if(text_num_bytes > STATIC_GLYPHS) {
#ifdef USE_FRIBIDI
glyphs.bidi_levels = msSmallMalloc(text_num_bytes * sizeof(FriBidiLevel));

0 comments on commit 5b2c46a

Please sign in to comment.