fontforge/SOURCES/fontforge-20170731-covscan-issue-fix.patch
2021-09-09 16:42:40 +00:00

2684 lines
86 KiB
Diff

diff -urN fontforge-20170731.old/fontforge/asmfpst.c fontforge-20170731/fontforge/asmfpst.c
--- fontforge-20170731.old/fontforge/asmfpst.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/asmfpst.c 2018-09-23 14:50:31.558567689 +0530
@@ -810,13 +810,16 @@
match_len = j;
for ( i=0; i<match_len; ++i )
- if ( tables[i]==NULL || tables[i][0]==NULL )
-return( NULL );
-
+ if ( tables[i]==NULL || tables[i][0]==NULL ) {
+ free(tables);
+ return( NULL );
+ }
glyphs = morx_cg_FigureClasses(tables,match_len,
&classes,&class_cnt,&map,&gcnt,fpst,sf,ordered);
- if ( glyphs==NULL )
-return( NULL );
+ if ( glyphs==NULL ) {
+ free(tables);
+ return( NULL );
+ }
for ( i=0; i<match_len; ++i )
free(tables[i]);
diff -urN fontforge-20170731.old/fontforge/autotrace.c fontforge-20170731/fontforge/autotrace.c
--- fontforge-20170731.old/fontforge/autotrace.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/autotrace.c 2018-09-23 14:50:31.558567689 +0530
@@ -474,8 +474,10 @@
++cnt;
for ( start=pt; isspace(*start); ++start);
}
- if ( cnt==0 )
-return( NULL );
+ if ( cnt==0 ) {
+ free(vector);
+ return( NULL );
+ }
if ( vector ) {
vector[cnt] = NULL;
return( vector );
@@ -789,17 +791,17 @@
strcat(arglist[1],filename);
if ( (pid=fork())==0 ) {
/* Child */
- int fd;
+ int fdw, fdr;
chdir(tempdir);
if ( !mf_showerrors ) {
close(1); /* mf generates a lot of verbiage to stdout. Throw it away */
- fd = open("/dev/null",O_WRONLY);
- if ( fd!=1 )
- dup2(fd,1);
+ fdw = open("/dev/null",O_WRONLY);
+ if ( fdw!=1 )
+ dup2(fdw,1);
close(0); /* mf sometimes asks the user questions, but I have no answers... */
- fd = open("/dev/null",O_RDONLY);
- if ( fd!=0 )
- dup2(fd,0);
+ fdr = open("/dev/null",O_RDONLY);
+ if ( fdr!=0 )
+ dup2(fdr,0);
}
exit(execvp(arglist[0],arglist)==-1); /* If exec fails, then die */
} else if ( pid!=-1 ) {
@@ -836,6 +838,7 @@
ff_post_error(_("Can't run mf"),_("Can't run mf"));
free(arglist[1]);
cleantempdir(tempdir);
+ free(tempdir);
return( sf );
#endif
}
diff -urN fontforge-20170731.old/fontforge/bitmapchar.c fontforge-20170731/fontforge/bitmapchar.c
--- fontforge-20170731.old/fontforge/bitmapchar.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/bitmapchar.c 2018-09-23 14:50:31.558567689 +0530
@@ -371,6 +371,8 @@
}
}
}
+ free(bpt);
+ free(pt);
}
BDFProperties *BdfPropsCopy(BDFProperties *props, int cnt ) {
diff -urN fontforge-20170731.old/fontforge/cvimages.c fontforge-20170731/fontforge/cvimages.c
--- fontforge-20170731.old/fontforge/cvimages.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/cvimages.c 2018-09-23 14:50:31.558567689 +0530
@@ -223,11 +223,15 @@
break;
if ( ch!='(' ) {
ff_post_error( _("Not a plate file"), _("This does not seem to be a plate file\nExpected left paren"));
+ free(head);
+ free(spiros);
return;
}
ch = getc(plate);
if ( ch!='v' && ch!='o' && ch!='c' && ch!='[' && ch!=']' && ch!='z' ) {
ff_post_error( _("Not a plate file"), _("This does not seem to be a plate file\nExpected one of 'voc[]z'"));
+ free(head);
+ free(spiros);
return;
}
if ( cnt>=max )
@@ -251,6 +255,8 @@
} else {
if ( fscanf(plate,"%lg %lg )", &spiros[cnt].x, &spiros[cnt].y)!=2 ) {
ff_post_error( _("Not a plate file"), _("This does not seem to be a plate file\nExpected two real numbers"));
+ free(head);
+ free(spiros);
return;
}
++cnt;
diff -urN fontforge-20170731.old/fontforge/cvundoes.c fontforge-20170731/fontforge/cvundoes.c
--- fontforge-20170731.old/fontforge/cvundoes.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/cvundoes.c 2018-09-23 14:50:31.559567674 +0530
@@ -2637,6 +2637,7 @@
adjust->yadv.corrections = malloc(adjust->yadv.last_pixel_size-adjust->yadv.first_pixel_size+1);
memcpy(adjust->yadv.corrections,vr->adjust->yadv.corrections,adjust->yadv.last_pixel_size-adjust->yadv.first_pixel_size+1);
}
+ free(adjust);
}
static void PSTInto(SplineChar *sc,PST *pst,PST *frompst, struct lookup_subtable *sub) {
@@ -3898,6 +3899,7 @@
{
char* str = UndoToString( sc, undo );
printf("\n\n*** undo: %d\n%s\n", idx, str );
+ free(str);
}
printf("dumpUndoChain(end) %s\n", msg );
}
diff -urN fontforge-20170731.old/fontforge/encoding.c fontforge-20170731/fontforge/encoding.c
--- fontforge-20170731.old/fontforge/encoding.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/encoding.c 2018-09-23 14:50:31.560567658 +0530
@@ -757,6 +757,7 @@
if ( item->enc_name==NULL ) {
if ( no_windowing_ui ) {
ff_post_error(_("Bad encoding file format"),_("This file contains an unnamed encoding, which cannot be named in a script"));
+ free(head);
return( NULL );
}
if ( item==head && item->next==NULL )
diff -urN fontforge-20170731.old/fontforge/featurefile.c fontforge-20170731/fontforge/featurefile.c
--- fontforge-20170731.old/fontforge/featurefile.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/featurefile.c 2018-09-23 14:50:31.561567642 +0530
@@ -1620,9 +1620,10 @@
glyphs[lcnt].sc = NULL;
}
- if ( !needsclasses && lcnt==0 && sf->mark_class_cnt==0 )
+ if ( !needsclasses && lcnt==0 && sf->mark_class_cnt==0 ){
+ free(glyphs);
return; /* No anchor positioning, no ligature carets */
-
+ }
if ( sf->mark_class_cnt!=0 ) {
fprintf( out, "#Mark attachment classes (defined in GDEF, used in lookupflags)\n" );
for ( i=1; i<sf->mark_class_cnt; ++i ) {
@@ -1799,9 +1800,12 @@
}
}
}
+ free(langs);
}
}
+ free(scripts);
}
+ free(feats);
}
if (has_DFLT) { dump_header_languagesystem_hash_fe((gpointer)"DFLT dflt", (gpointer)"", (gpointer)out); }
g_tree_foreach( ht, dump_header_languagesystem_hash_fe, out );
@@ -3259,15 +3263,18 @@
LogError(_("Expected '=' in glyph class definition on line %d of %s"), tok->line[tok->inc_depth], tok->filename[tok->inc_depth] );
++tok->err_count;
fea_skip_to_semi(tok);
+ free(classname);
return;
}
fea_ParseTok(tok);
contents = fea_ParseGlyphClass(tok); // Make a list of referenced glyphs.
if ( contents==NULL ) {
fea_skip_to_semi(tok);
+ free(contents);
return;
}
fea_AddClassDef(tok,classname,copy(contents)); // Put the list into a class.
+ free(contents);
fea_end_statement(tok);
}
@@ -3517,6 +3524,7 @@
LogError(_("Expected name in anchor definition on line %d of %s"), tok->line[tok->inc_depth], tok->filename[tok->inc_depth] );
++tok->err_count;
fea_skip_to_semi(tok);
+ free(ap);
return;
}
for ( nap=tok->namedAnchors; nap!=NULL; nap=nap->next )
@@ -3681,6 +3689,7 @@
LogError(_("Expected class name in mark class definition on line %d of %s"), tok->line[tok->inc_depth], tok->filename[tok->inc_depth] );
++tok->err_count;
fea_skip_to_semi(tok);
+ free(ap);
return;
}
gm = chunkalloc(sizeof(*gm));
@@ -4639,7 +4648,7 @@
}
r->lookup_cnt = lc;
}
-
+ free(bcovers);
return( fpst );
}
@@ -7092,6 +7101,7 @@
}
if ( f!=NULL && f->type == ft_feat_end )
f = f->next;
+ free(sl);
return( f );
}
diff -urN fontforge-20170731.old/fontforge/glyphcomp.c fontforge-20170731/fontforge/glyphcomp.c
--- fontforge-20170731.old/fontforge/glyphcomp.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/glyphcomp.c 2018-09-23 14:50:31.562567627 +0530
@@ -1414,7 +1414,10 @@
static void NameCompare(struct font_diff *fd,const char *name1, const char *name2, char *id) {
- if (!name1) name1=""; if (!name2) name2="";
+ if (!name1)
+ name1="";
+ if (!name2)
+ name2="";
if ( strcmp(name1,name2)!=0 ) {
if ( !fd->top_diff )
fprintf( fd->diffs, "Names\n" );
@@ -1442,7 +1445,10 @@
int lang,int strid) {
char strnamebuf[200];
- if (!name1) name1=""; if (!name2) name2="";
+ if (!name1)
+ name1="";
+ if (!name2)
+ name2="";
if ( strcmp(name1,name2)==0 )
return;
sprintf( strnamebuf, "%.90s %.90s", TTFNameIds(strid), MSLangString(lang));
diff -urN fontforge-20170731.old/fontforge/http.c fontforge-20170731/fontforge/http.c
--- fontforge-20170731.old/fontforge/http.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/http.c 2018-09-23 14:50:31.562567627 +0530
@@ -540,7 +540,9 @@
if ( !findFTPhost(&addr, host, port)) {
ff_progress_end_indicator();
ff_post_error(_("Could not find host"),_("Could not find \"%s\"\nAre you connected to the internet?"), host );
- free( host ); free( filename );
+ free( host );
+ free( filename );
+ free(password);
return( false );
}
soc = makeConnection(&addr);
diff -urN fontforge-20170731.old/fontforge/lookups.c fontforge-20170731/fontforge/lookups.c
--- fontforge-20170731.old/fontforge/lookups.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/lookups.c 2018-09-23 14:50:31.562567627 +0530
@@ -4746,20 +4746,26 @@
break;
start = lpt;
if ( *start=='|' ) {
- if ( fpst->type==pst_contextpos || fpst->type==pst_contextsub )
-return( xasprintf( _("Separation marks only meaningful in contextual chaining lookups, starting at: %.20s..."), lpt ));
+ if ( fpst->type==pst_contextpos || fpst->type==pst_contextsub ){
+ free(parsed);
+ return( xasprintf( _("Separation marks only meaningful in contextual chaining lookups, starting at: %.20s..."), lpt ));
+ }
if ( first==-1 )
first = cnt;
else if ( last==-1 )
last = cnt-1;
- else
-return( xasprintf( _("Too many separation marks, starting at: %.20s..."), lpt ));
+ else{
+ free(parsed);
+ return( xasprintf( _("Too many separation marks, starting at: %.20s..."), lpt ));
+ }
++lpt;
continue;
} else if ( *start=='[' ) {
/* A coverage table */
- if ( fpst->format!=pst_coverage && fpst->format!=pst_reversecoverage )
-return( xasprintf( _("A coverage table was found in a glyph or class based contextual lookup, starting at: %.20s..."), lpt ));
+ if ( fpst->format!=pst_coverage && fpst->format!=pst_reversecoverage ){
+ free(parsed);
+ return( xasprintf( _("A coverage table was found in a glyph or class based contextual lookup, starting at: %.20s..."), lpt ));
+ }
++start;
for ( lpt = start; *lpt!='\0' && *lpt!=']'; ++lpt );
if ( *lpt!=']' )
@@ -4788,9 +4794,10 @@
}
free(parsed[cnt].replacements);
parsed[cnt].replacements = newr;
- } else
-return( xasprintf( _("There must be as many replacement glyphs as there are match glyphs: %s => %s"),
+ } else{
+ return( xasprintf( _("There must be as many replacement glyphs as there are match glyphs: %s => %s"),
parsed[cnt].entity, parsed[cnt].replacements));
+ }
continue;
}
} else if ( *start!='@' && *start!='<' && !(*start=='=' && start[1]=='>') ) {
@@ -4802,14 +4809,18 @@
/* A reverse contextual chaining */
if ( fpst->format!=pst_reversecoverage )
return( xasprintf( _("No replacement lists may be specified in this contextual lookup, use a nested lookup instead, starting at: %.20s..."), lpt ));
- if ( do_replacements )
-return( xasprintf( _("Only one replacement list may be specified in a reverse contextual chaining lookup, starting at: %.20s..."), lpt ));
+ if ( do_replacements ) {
+ free(parsed);
+ return( xasprintf( _("Only one replacement list may be specified in a reverse contextual chaining lookup, starting at: %.20s..."), lpt ));
+ }
do_replacements = true;
lpt += 2;
} else {
/* A lookup invocation */
- if ( fpst->format==pst_reversecoverage )
-return( xasprintf( _("No lookups may be specified in a reverse contextual lookup (use a replacement list instead), starting at: %.20s..."), lpt ));
+ if ( fpst->format==pst_reversecoverage ){
+ free(parsed);
+ return( xasprintf( _("No lookups may be specified in a reverse contextual lookup (use a replacement list instead), starting at: %.20s..."), lpt ));
+ }
if ( *start=='@' ) {
for ( lpt=start+1; isspace( *lpt ); ++lpt );
@@ -4867,8 +4878,10 @@
ret = NULL;
if ( !do_replacements && !anylookup ) {
- if ( fpst->format==pst_reversecoverage )
-return( copy( _("A reverse contextual chaining lookup must have a set of replacement glyphs somewhere" )) );
+ if ( fpst->format==pst_reversecoverage ) {
+ free(parsed);
+ return( copy( _("A reverse contextual chaining lookup must have a set of replacement glyphs somewhere" )) );
+ }
else {
*return_is_warning = true;
/* If there are no lookups then this rule matches and does nothing */
@@ -4884,8 +4897,10 @@
if ( first==-1 ) first = i;
}
if ( parsed[i].replacements!=NULL ) {
- if (( first!=-1 && first!=i ) || (last!=-1 && last!=i ))
-return( copy( _("A reverse contextual chaining lookup can only match one coverage table directly" )) );
+ if (( first!=-1 && first!=i ) || (last!=-1 && last!=i )){
+ free(parsed);
+ return( copy( _("A reverse contextual chaining lookup can only match one coverage table directly" )) );
+ }
first = last = i;
}
}
@@ -4977,11 +4992,13 @@
free( rule->u.class.fclasses ); rule->u.class.fclasses = NULL;
rule->u.class.bcnt = rule->u.class.fcnt = rule->u.class.ncnt = 0;
if ( i<first )
-return( xasprintf( _("%s is not a class name for the backtracking classes." ), parsed[i].entity ) );
- else if ( i<=last )
-return( xasprintf( _("%s is not a class name for the matching classes." ), parsed[i].entity ) );
+ return( xasprintf( _("%s is not a class name for the backtracking classes." ), parsed[i].entity ) );
+ else if ( i<=last ) {
+ free(ret);
+ return( xasprintf( _("%s is not a class name for the matching classes." ), parsed[i].entity ) );
+ }
else
-return( xasprintf( _("%s is not a class name for the forward classes." ), parsed[i].entity ) );
+ return( xasprintf( _("%s is not a class name for the forward classes." ), parsed[i].entity ) );
}
if ( i<first )
rule->u.class.bclasses[first-1-i] = j; /* Reverse the backtrack classes */
diff -urN fontforge-20170731.old/fontforge/macbinary.c fontforge-20170731/fontforge/macbinary.c
--- fontforge-20170731.old/fontforge/macbinary.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/macbinary.c 2018-09-23 14:50:31.563567611 +0530
@@ -299,7 +299,8 @@
for (;;) {
if ( getc(pfbfile)!=0x80 ) {
IError("We made a pfb file, but didn't get one. Hunh?" );
-return( NULL );
+ free(resstarts);
+ return( NULL );
}
type = getc(pfbfile);
if ( type==3 ) {
@@ -1833,8 +1834,12 @@
strcpy(pt-1,".fam.bin");
#endif
}
- if ( WriteMacPSFont(tempname,sfi->sf,format,flags,sfi->map,layer)==0 )
-return( 0 );
+ if ( WriteMacPSFont(tempname,sfi->sf,format,flags,sfi->map,layer)==0 ){
+ free(filename);
+ free(tempname);
+ return( 0 );
+ }
+
free(tempname);
}
} else if ( format!=ff_none || bf==bf_sfnt_dfont ) {
@@ -1861,7 +1866,8 @@
if ( res==NULL ) {
for ( sfsub=sfs; sfsub!=NULL; sfsub=sfsub->next )
fclose( sfsub->tempttf );
-return( 0 );
+ free(filename);
+ return( 0 );
}
if ( format==ff_ttfdfont || format==ff_otfdfont || format==ff_otfciddfont ||
@@ -1982,8 +1988,9 @@
if ( pfb==NULL ) {
LogError( _("Can't open temporary file for postscript output\n") );
fseek(f,here,SEEK_SET );
+ free(rsrcids);
free(offsets);
-return(NULL);
+ return(NULL);
}
putc(0x80,pfb);
@@ -2578,7 +2585,9 @@
char *pt, *lparen;
char *find = NULL;
- if ((pt = strrchr(filename,'/'))!=NULL ) pt = filename;
+ if ((pt = strrchr(filename,'/'))!=NULL )
+ pt = filename;
+
if ( (lparen = strchr(filename,'('))!=NULL && strchr(lparen,')')!=NULL ) {
find = copy(lparen+1);
pt = strchr(find,')');
@@ -2588,6 +2597,8 @@
if ( test->psnames[i]!=NULL && strcmp(find,test->psnames[i])==0 ) {
*style = (i&3) | ((i&~3)<<1); /* PS styles skip underline bit */
*name = copy(test->psnames[i]);
+ free(find);
+ free(pt);
return( test );
}
}
@@ -2670,8 +2681,10 @@
SplineChar *sc;
fond = PickFOND(fondlist,filename,&name,&style);
- if ( fond==NULL )
-return( NULL );
+ if ( fond==NULL ){
+ free(name);
+ return( NULL );
+ }
find_id=-1;
if ( flags&ttf_onlyonestrike ) {
@@ -2747,8 +2760,11 @@
SplineChar *sc1, *sc2;
fond = PickFOND(fondlist,filename,&name,&style);
- if ( fond==NULL || into==NULL )
-return( NULL );
+ if ( fond==NULL || into==NULL ){
+ free(name);
+ return( NULL );
+ }
+
for ( i=0; i<fond->stylekerncnt; ++i )
if ( fond->stylekerns[i].style==style )
break;
@@ -2780,6 +2796,7 @@
}
kp->off = offset;
}
+ free(name);
return( into );
}
@@ -2795,7 +2812,11 @@
char **ret;
char *temp = TTFGetFontName(binary,pos,pos);
if ( temp==NULL )
-return( NULL );
+ {
+ free(temp);
+ free(buffer);
+ return( NULL );
+ }
ret = malloc(2*sizeof(char *));
ret[0] = temp;
ret[1] = NULL;
diff -urN fontforge-20170731.old/fontforge/palmfonts.c fontforge-20170731/fontforge/palmfonts.c
--- fontforge-20170731.old/fontforge/palmfonts.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/palmfonts.c 2018-09-23 14:50:31.563567611 +0530
@@ -178,6 +178,7 @@
BCCompressBitmap(bdfc);
}
}
+ free(fontImage);
}
static SplineFont *PalmTestFont(FILE *file,int end, char *family,const char *style) {
@@ -440,6 +441,7 @@
putlong(file,0);
putlong(file,0);
}
+ free(pt1);
return(file);
}
diff -urN fontforge-20170731.old/fontforge/parsepdf.c fontforge-20170731/fontforge/parsepdf.c
--- fontforge-20170731.old/fontforge/parsepdf.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/parsepdf.c 2018-09-23 14:50:31.564567596 +0530
@@ -974,8 +974,11 @@
while ( prev_xref!=-1 ) {
if ( fseek(pdf,prev_xref,SEEK_SET)!=0 ) return( NULL );
pdf_skipobjectheader(pc);
- if ( !pdf_readdict(pc))
-return( NULL );
+ if ( !pdf_readdict(pc)){
+ free(gen);
+ free(ret);
+ return( NULL );
+ }
if ( (pt=PSDictHasEntry(&pc->pdfdict,"Type"))==NULL || strcmp(pt,"/XRef")!=0 )
return( NULL );
if ( (pt=PSDictHasEntry(&pc->pdfdict,"Size"))==NULL )
@@ -2069,6 +2072,7 @@
pcFree(&pc);
fclose(pc.pdf);
switch_to_old_locale(&tmplocale, &oldlocale); // Switch to the cached locale.
+ free(list);
return( NULL );
}
diff -urN fontforge-20170731.old/fontforge/parsettfatt.c fontforge-20170731/fontforge/parsettfatt.c
--- fontforge-20170731.old/fontforge/parsettfatt.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/parsettfatt.c 2018-09-23 14:50:31.564567596 +0530
@@ -790,6 +790,7 @@
if ( feof(ttf) ) {
LogError( _("Bad mark table.\n") );
info->bad_ot = true;
+ free(classes);
return( NULL );
}
@@ -1386,6 +1387,7 @@
if ( glyphs==NULL ) {
/* GT: This continues a multi-line error message, hence the leading space */
LogError( _(" Bad contextual substitution table, ignored\n") );
+ free(class);
free(rules);
return;
}
@@ -1543,6 +1545,7 @@
if ( glyphs==NULL ) {
/* GT: This continues a multi-line error message, hence the leading space */
LogError( _(" Bad contextual chaining substitution table, ignored\n") );
+ free(class);
free(rules);
return;
}
@@ -2443,6 +2446,7 @@
if ( pos+scripts[i].languages[j].offset>=info->g_bounds ) {
LogError(_("Attempt to read script data beyond end of %s table"), isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(scripts);
return( NULL );
}
fseek(ttf,pos+scripts[i].languages[j].offset,SEEK_SET);
@@ -2452,6 +2456,7 @@
if ( feof(ttf)) {
LogError(_("End of file when reading scripts in %s table"), isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(scripts);
return( NULL );
}
scripts[i].languages[j].features = malloc(scripts[i].languages[j].fcnt*sizeof(uint16));
@@ -2463,6 +2468,7 @@
if ( feof(ttf)) {
LogError(_("End of file in %s table"), isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(scripts);
return( NULL );
}
@@ -2502,6 +2508,7 @@
if ( pos+features[i].offset>=info->g_bounds ) {
LogError(_("Attempt to read feature data beyond end of %s table"), isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(features);
return( NULL );
}
fseek(ttf,pos+features[i].offset,SEEK_SET);
@@ -2518,6 +2525,7 @@
if ( feof(ttf) ) {
LogError(_("End of file when reading features in %s table"), isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(features);
return( NULL );
}
features[i].lookups = malloc(features[i].lcnt*sizeof(uint16));
@@ -2560,6 +2568,7 @@
LogError(_("Attempt to read lookup data beyond end of %s table"),
isgpos==2? "JSTF" : isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(lookups);
return( NULL );
}
fseek(ttf,pos+lookups[i].offset,SEEK_SET);
@@ -2585,6 +2594,7 @@
if ( feof(ttf) ) {
LogError(_("End of file when reading lookups in %s table"), isgpos ? "GPOS" : "GSUB" );
info->bad_ot = true;
+ free(lookups);
return( NULL );
}
for ( j=0; j<lookups[i].subtabcnt; ++j ) {
@@ -6063,6 +6073,7 @@
LogError( _("JSTF table is too long.\n") );
info->bad_ot = true;
free(soff);
+ free(loff);
return;
}
diff -urN fontforge-20170731.old/fontforge/parsettfbmf.c fontforge-20170731/fontforge/parsettfbmf.c
--- fontforge-20170731.old/fontforge/parsettfbmf.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/parsettfbmf.c 2018-09-23 14:50:31.565567580 +0530
@@ -91,8 +91,8 @@
/* Only use the provided metrics if it hasn't already been set */
if (metrics == NULL)
metrics = &big;
- if ( imageformat==8 )
- /* pad = */ getc(ttf);
+ if ( imageformat==8 )
+ /* pad = */ getc(ttf);
} else if ( imageformat==6 || imageformat==7 || imageformat==9 ) {
big.height = getc(ttf);
big.width = getc(ttf);
diff -urN fontforge-20170731.old/fontforge/parsettf.c fontforge-20170731/fontforge/parsettf.c
--- fontforge-20170731.old/fontforge/parsettf.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/parsettf.c 2018-09-23 14:50:31.566567564 +0530
@@ -1972,7 +1972,8 @@
info->bad_glyph_data = true;
LogError( _("Bad tt font: contour ends make no sense in glyph %d.\n"),
sc->orig_pos );
-return;
+ free(endpt);
+ return;
}
}
if ( path_cnt==0 ) {
diff -urN fontforge-20170731.old/fontforge/parsettfvar.c fontforge-20170731/fontforge/parsettfvar.c
--- fontforge-20170731.old/fontforge/parsettfvar.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/parsettfvar.c 2018-09-23 14:50:31.567567549 +0530
@@ -747,6 +747,7 @@
ti = -1;
if ( k!=info->variations->tuple_count )
ti = k;
+ free(coords);
}
if ( ti!=-1 ) {
here = ftell(ttf);
diff -urN fontforge-20170731.old/fontforge/plugins.c fontforge-20170731/fontforge/plugins.c
--- fontforge-20170731.old/fontforge/plugins.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/plugins.c 2018-09-23 14:50:31.567567549 +0530
@@ -35,6 +35,7 @@
int LoadPlugin(const char *dynamic_lib_name) {
lt_dlhandle plugin;
plugin = load_plugin(dynamic_lib_name, LogError);
+ free(plugin);
return (plugin != NULL);
}
diff -urN fontforge-20170731.old/fontforge/print.c fontforge-20170731/fontforge/print.c
--- fontforge-20170731.old/fontforge/print.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/print.c 2018-09-23 14:50:31.568567533 +0530
@@ -2894,6 +2894,7 @@
}
if ( pt>start && i<sizeof(argv)/sizeof(argv[0])-1 )
argv[i++] = start;
+ free(temp);
}
argv[i] = NULL;
/*for ( i=0; argv[i]!=NULL; ++i ) printf( "%s ", argv[i]); printf("\n" );*/
diff -urN fontforge-20170731.old/fontforge/psread.c fontforge-20170731/fontforge/psread.c
--- fontforge-20170731.old/fontforge/psread.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/psread.c 2018-09-23 14:50:31.569567518 +0530
@@ -295,7 +295,9 @@
wrapper->top = io->prev;
if ( io->isstopped )
wrapper->endedstopped = true;
- if (io->start != NULL) free(io->start); io->start = NULL;
+ if (io->start != NULL)
+ free(io->start);
+ io->start = NULL;
free(io);
io = wrapper->top;
}
@@ -353,7 +355,9 @@
while ( io->prev!=NULL && !io->isstopped ) {
iop = io->prev;
wasloop = io->isloop;
- if (io->start != NULL) free(io->start); io->start = NULL;
+ if (io->start != NULL)
+ free(io->start);
+ io->start = NULL;
free(io);
if ( wasloop ) {
wrapper->top = iop;
@@ -377,7 +381,9 @@
while ( io->prev!=NULL ) {
iop = io->prev;
wasstopped = io->isstopped;
- if (io->start != NULL) free(io->start); io->start = NULL;
+ if (io->start != NULL)
+ free(io->start);
+ io->start = NULL;
free(io);
if ( wasstopped ) {
wrapper->top = iop;
@@ -2292,8 +2298,14 @@
int mx, mn;
real h, s, b;
mx = mn = r;
- if ( mx>g ) mn=g; else mx=g;
- if ( mx<bl ) mx = bl; if ( mn>bl ) mn = bl;
+ if ( mx>g )
+ mn=g;
+ else
+ mx=g;
+ if ( mx<bl )
+ mx = bl;
+ if ( mn>bl )
+ mn = bl;
b = mx/255.;
s = h = 0;
if ( mx>0 )
@@ -3364,8 +3376,10 @@
encname = copy(tokbuf);
tok = nextpstoken(&wrapper,&dval,tokbuf,sizeof(tokbuf));
}
- if ( tok!=pt_openarray && tok!=pt_opencurly )
+ if ( tok!=pt_openarray && tok!=pt_opencurly ){
+ free(encname);
return( head );
+ }
for ( i=0; i<sizeof(names)/sizeof(names[0]); ++i ) {
encs[i] = -1;
names[i]=NULL;
@@ -4675,5 +4689,7 @@
HintsRenumber(ret);
if ( name!=NULL && strcmp(name,".notdef")!=0 )
ret->widthset = true;
+ free(pending_hm);
+ free(pt);
return( ret );
}
diff -urN fontforge-20170731.old/fontforge/python.c fontforge-20170731/fontforge/python.c
--- fontforge-20170731.old/fontforge/python.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/python.c 2018-09-23 14:50:31.572567471 +0530
@@ -1183,6 +1183,7 @@
tuple = PyTuple_New(cnt);
for ( i=0; i<cnt; ++i )
PyTuple_SetItem(tuple,i,Py_BuildValue("s",ret[i]));
+ free(ret);
return( tuple );
}
@@ -1618,6 +1619,7 @@
PyErr_Format(PyExc_ValueError, "Value out of bounds for 4th argument");
free(title);
free(quest);
+ free(answers);
return( NULL );
}
for ( i=0; i<cnt; ++i ) {
@@ -2187,10 +2189,12 @@
ss = SSFromContour(self,NULL);
if ( ss==NULL ) {
PyErr_SetString(PyExc_AttributeError, "Empty Contour");
+ free(ss);
return( NULL );
}
self->spiros = SplineSet2SpiroCP(ss,&cnt);
self->spiro_cnt = cnt;
+ free(ss);
}
spirotuple = PyTuple_New(self->spiro_cnt-1);
for ( i=0; i<self->spiro_cnt-1; ++i ) {
@@ -2893,7 +2897,10 @@
for ( i=0; i<PySequence_Size(args); ++i ) {
pos = PyInt_AsLong(PySequence_GetItem(args,i));
if ( PyErr_Occurred())
-return( NULL );
+ {
+ free(ss);
+ return( NULL );
+ }
SSSelectOnCurve(ss,pos);
}
SplineCharMerge(NULL,&ss,1);
@@ -2960,8 +2967,10 @@
smpl.linefixup = PyFloat_AsDouble( PySequence_GetItem(args,3));
if ( !PyErr_Occurred() && PySequence_Size(args)>=5 )
smpl.linelenmax = PyFloat_AsDouble( PySequence_GetItem(args,4));
- if ( PyErr_Occurred() )
+ if ( PyErr_Occurred() ){
+ free(ss);
return( NULL );
+ }
SplinePointListSimplify(NULL,ss,&smpl);
if ( ss==NULL ) {
for ( i=0; i<self->pt_cnt; ++i )
@@ -3292,6 +3301,7 @@
do_pycall(pen,"qCurveTo",tuple);
} else {
PyErr_Format(PyExc_TypeError, "Wrong number of off-curve points on a cubic contour");
+ free(points);
return( NULL );
}
if ( PyErr_Occurred())
@@ -3324,6 +3334,7 @@
if ( PyErr_Occurred())
return( NULL );
+free(points);
Py_RETURN( self );
}
@@ -3612,6 +3623,7 @@
ss2 = SSFromLayer((PyFF_Layer *) other);
} else {
PyErr_Format(PyExc_TypeError, "Unexpected type");
+ free(ss);
return( -1 );
}
ret = SSsCompare(ss,ss2,pt_err,spline_err,&badpoint);
@@ -3880,8 +3892,10 @@
smpl.linefixup = PyFloat_AsDouble( PySequence_GetItem(args,3));
if ( !PyErr_Occurred() && PySequence_Size(args)>=5 )
smpl.linelenmax = PyFloat_AsDouble( PySequence_GetItem(args,4));
- if ( PyErr_Occurred() )
+ if ( PyErr_Occurred() ){
+ free(ss);
return( NULL );
+ }
ss = SplineCharSimplify(NULL,ss,&smpl);
LayerFromSS(ss,self);
SplinePointListsFree(ss);
@@ -4187,8 +4201,10 @@
SplinePointListsFree(ss);
ss = temp;
}
- if ( !PolyCheck(ss))
+ if ( !PolyCheck(ss)){
+ free(ss);
return( -1 );
+ }
si->poly = ss;
} else if ( width<=0 || minor<=0 ) {
PyErr_Format(PyExc_ValueError, "Stroke width must be positive" );
@@ -4765,7 +4781,9 @@
++nexti;
if ( c->points[nexti]->on_curve ) {
PyErr_Format(PyExc_TypeError, "In cubic splines there must be exactly 2 control points between on curve points");
-return( NULL );
+ free(ss);
+ free(sp);
+ return( NULL );
}
if ( nexti==c->pt_cnt-1 )
nexti = 0;
@@ -4773,7 +4791,9 @@
++nexti;
if ( !c->points[nexti]->on_curve ) {
PyErr_Format(PyExc_TypeError, "In cubic splines there must be exactly 2 control points between on curve points");
-return( NULL );
+ free(sp);
+ free(ss);
+ return( NULL );
}
}
if ( ss->last==NULL ) {
@@ -4785,6 +4805,7 @@
}
if ( ss->last==NULL ) {
PyErr_Format(PyExc_TypeError, "Empty contour");
+ free(ss);
return( NULL );
}
}
@@ -6064,8 +6085,10 @@
PyErr_Format(PyExc_TypeError, "Unexpected type");
return( -1 );
}
- if ( self->sc->layers[self->layer].refs!=NULL )
+ if ( self->sc->layers[self->layer].refs!=NULL ){
+ free(ss2);
return( SS_NoMatch | SS_RefMismatch );
+ }
ret = SSsCompare(self->sc->layers[self->layer].splines,ss2,pt_err,spline_err,&badpoint);
SplinePointListsFree(ss2);
return(ret);
@@ -6274,8 +6297,10 @@
uni = 0; vs = -1; fid = 0;
if ( PyInt_Check(obj))
uni = PyInt_AsLong(obj);
- else if ( !PyArg_ParseTuple(obj,"i|ii", &uni, &vs, &fid))
+ else if ( !PyArg_ParseTuple(obj,"i|ii", &uni, &vs, &fid)){
+ free(head);
return( -1 );
+ }
cur = chunkalloc(sizeof(struct altuni));
if ( vs==0 ) vs=-1; /* convention used in charinfo */
cur->unienc = uni; cur->vs = vs; cur->fid = fid;
@@ -6738,7 +6763,10 @@
return( -1 );
for ( i=0; i<cnt; ++i ) {
if ( !PyArg_ParseTuple(PySequence_GetItem(value,i),"dd", &start, &width ))
+ {
+ free(tail);
return( -1 );
+ }
cur = chunkalloc(sizeof(StemInfo));
if ( width==-20 || width==-21 )
cur->ghost = true;
@@ -7036,8 +7064,10 @@
for ( i=0; i<PySequence_Size(value); ++i ) {
ap = APFromTuple(sc,PySequence_GetItem(value,i));
- if ( ap==NULL )
-return( -1 );
+ if ( ap==NULL ){
+ free(aplast);
+ return( -1 );
+ }
if ( aphead==NULL )
aphead = ap;
else
@@ -7250,6 +7280,7 @@
self->sc->vert_variants = chunkalloc(sizeof(struct glyphvariants));
self->sc->vert_variants->variants = copy(str);
}
+ free(str);
return( 0 );
}
@@ -7276,6 +7307,7 @@
self->sc->horiz_variants = chunkalloc(sizeof(struct glyphvariants));
self->sc->horiz_variants->variants = copy(str);
}
+ free(str);
return( 0 );
}
@@ -7761,6 +7793,7 @@
SCCharChangedUpdate(sc,((PyFF_Glyph *) self)->layer);
+ free(ap);
Py_RETURN( self );
}
@@ -8137,6 +8170,7 @@
}
if ( deltalen==0 ) {
PyErr_Format(PyExc_TypeError,"Glyph name strings may not be empty");
+ free(str);
return( NULL );
}
len += deltalen+1;
@@ -8575,6 +8609,7 @@
old = NULL;
} else {
PyErr_Format(PyExc_KeyError, "Unexpected lookup type: %s",sub->lookup->lookup_name);
+ free(other);
return( NULL );
}
temp.u.subs.variant = other;
@@ -13659,6 +13694,7 @@
ext = locfilename+len-2;
if ( ext[0]!='p' || ext[1]!='k' ) {
PyErr_Format(PyExc_EnvironmentError, "No extension for bitmap font");
+ free(ext);
return( NULL );
}
}
@@ -13673,7 +13709,8 @@
back = true;
} else {
PyErr_Format(PyExc_EnvironmentError, "Bad extension for bitmap font");
-return( NULL );
+ free(ext);
+ return( NULL );
}
if ( to_background!=-1 )
back = to_background;
@@ -13732,8 +13769,10 @@
free(locfilename);
return( NULL );
}
- if ( CheckIfFontClosed(other) )
+ if ( CheckIfFontClosed(other) ){
+ free(locfilename);
return (NULL);
+ }
flags = FlagsFromTuple(flagstuple,compflags,"comparison flag");
if ( flags==FLAG_UNKNOWN ) {
free(locfilename);
@@ -14316,6 +14355,8 @@
if ( offsets!=NULL ) {
if ( cnt1*cnt2 != PySequence_Size(offsets) ) {
PyErr_Format(PyExc_ValueError, "There aren't enough kerning offsets for the number of kerning classes. Should be %d", cnt1*cnt2 );
+ free(class1_strs);
+ free(class2_strs);
return( NULL );
}
offs = malloc(cnt1*cnt2*sizeof(int16));
@@ -14323,7 +14364,9 @@
offs[i] = PyInt_AsLong(PySequence_GetItem(offsets,i));
if ( PyErr_Occurred()) {
free(offs);
-return( NULL );
+ free(class1_strs);
+ free(class2_strs);
+ return( NULL );
}
}
} else
@@ -14333,6 +14376,8 @@
sub = addLookupSubtable(sf, lookup, subtable, after_str);
if ( sub==NULL ) {
free(offs);
+ free(class1_strs);
+ free(class2_strs);
return( NULL );
}
if ( sub->lookup->lookup_type!=gpos_pair ) {
@@ -14407,6 +14452,8 @@
cnt2 = ParseClassNames(class2s,&class2_strs);
if ( cnt1*cnt2 != PySequence_Size(offsets) ) {
PyErr_Format(PyExc_ValueError, "There aren't enough kerning offsets for the number of kerning classes. Should be %d", cnt1*cnt2 );
+ free(class1_strs);
+ free(class2_strs);
return( NULL );
}
offs = malloc(cnt1*cnt2*sizeof(int16));
@@ -15266,6 +15313,7 @@
mcnt = ParseClassNames(mclasses,&matchclasses);
if ( mcnt==-1 ) {
PyErr_Format(PyExc_TypeError, "Bad match class" );
+ free(matchclasses);
return( NULL );
}
if ( mclassnames!=NULL ) {
@@ -15305,6 +15353,7 @@
new_subtable = addLookupSubtable(sf, lookup, subtable, after_str);
if ( new_subtable==NULL ) {
free(backclassnames); free(matchclasses); free(forclasses);
+ free(matchclassnames);
return( NULL );
}
fpst = chunkalloc(sizeof(FPST));
@@ -15495,6 +15544,7 @@
rpl_ss = SSFromContour((PyFF_Contour *) rpl, NULL);
} else {
PyErr_Format(PyExc_TypeError, "Expected a contour or layer");
+ free(srch_ss);
return( NULL );
}
@@ -15939,11 +15989,13 @@
last = cur;
} else {
PyErr_Format(PyExc_TypeError, "Second argument must be either a font or a list of fonts");
+ free(head);
return( NULL );
}
}
} else {
PyErr_Format(PyExc_TypeError, "Second argument must be either a font or a list of fonts");
+ free(head);
return( NULL );
}
@@ -15982,6 +16034,7 @@
otl = SFFindLookup(fv->sf,lookup_name);
if ( otl == NULL ) {
PyErr_Format(PyExc_EnvironmentError, "No lookup named %s", lookup_name );
+ free(locfilename);
return( NULL );
}
}
@@ -16080,6 +16133,7 @@
if ( sf->fv==NULL )
EncMapFree(sf->map);
newfv = SFAdd(InterpolateFont(fv->sf,sf,fraction, fv->map->enc ),false);
+ free(sf);
return( PyFV_From_FV_I(newfv));
}
diff -urN fontforge-20170731.old/fontforge/savefont.c fontforge-20170731/fontforge/savefont.c
--- fontforge-20170731.old/fontforge/savefont.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/savefont.c 2018-09-23 14:50:31.573567455 +0530
@@ -313,8 +313,10 @@
char *buf = malloc(strlen(filename)+12), *pt;
FILE *flog;
- if ( sf->fontlog==NULL || *sf->fontlog=='\0' )
-return( true );
+ if ( sf->fontlog==NULL || *sf->fontlog=='\0' ) {
+ free(buf);
+ return( true );
+ }
strcpy(buf,filename);
pt = strrchr(buf,'/');
diff -urN fontforge-20170731.old/fontforge/scstyles.c fontforge-20170731/fontforge/scstyles.c
--- fontforge-20170731.old/fontforge/scstyles.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/scstyles.c 2018-09-23 14:50:31.575567424 +0530
@@ -2578,7 +2578,8 @@
for ( j=0; j<tot; ++j ) {
if ( overlaps[j].new_start == -10000 ) {
IError( "Hint zone not positioned" );
-return;
+ free(overlaps);
+ return;
}
}
diff -urN fontforge-20170731.old/fontforge/search.c fontforge-20170731/fontforge/search.c
--- fontforge-20170731.old/fontforge/search.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/search.c 2018-09-23 14:50:31.575567424 +0530
@@ -808,7 +808,8 @@
/* Total "fudge" amount should be spread evenly over each point */
FudgeFigure(s,path,&fudge);
if ( s->pointcnt!=s->rpointcnt )
- MinimumDistancesFree(sc->md); sc->md = NULL;
+ MinimumDistancesFree(sc->md);
+ sc->md = NULL;
sc_p = s->matched_sp; p_p = path->first, r_p = rpath->first;
if ( s->endpoints ) {
diff -urN fontforge-20170731.old/fontforge/sfd.c fontforge-20170731/fontforge/sfd.c
--- fontforge-20170731.old/fontforge/sfd.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/sfd.c 2018-09-23 14:50:31.576567408 +0530
@@ -7924,10 +7924,14 @@
{
char* sname = SFDReadUTF7Str(sfd);
if (sf->pfminfo.stylemap == -1) {
- if (strcmp(sname,"bold italic")==0) sf->pfminfo.stylemap = 0x21;
- else if (strcmp(sname,"bold")==0) sf->pfminfo.stylemap = 0x20;
- else if (strcmp(sname,"italic")==0) sf->pfminfo.stylemap = 0x01;
- else if (strcmp(sname,"regular")==0) sf->pfminfo.stylemap = 0x40;
+ if (strcmp(sname,"bold italic")==0)
+ sf->pfminfo.stylemap = 0x21;
+ else if (strcmp(sname,"bold")==0)
+ sf->pfminfo.stylemap = 0x20;
+ else if (strcmp(sname,"italic")==0)
+ sf->pfminfo.stylemap = 0x01;
+ else if (strcmp(sname,"regular")==0)
+ sf->pfminfo.stylemap = 0x40;
}
free(sname);
}
@@ -8010,7 +8014,8 @@
{
/* Class 0 is unused */
int temp;
- while ( (temp=nlgetc(sfd))=='\n' || temp=='\r' ); ungetc(temp,sfd);
+ while ( (temp=nlgetc(sfd))=='\n' || temp=='\r' );
+ ungetc(temp,sfd);
sf->mark_class_names[i] = SFDReadUTF7Str(sfd);
getint(sfd,&temp);
sf->mark_classes[i] = malloc(temp+1); sf->mark_classes[i][temp] = '\0';
@@ -8027,10 +8032,12 @@
{
/* Set 0 is used */
int temp;
- while ( (temp=nlgetc(sfd))=='\n' || temp=='\r' ); ungetc(temp,sfd);
+ while ( (temp=nlgetc(sfd))=='\n' || temp=='\r' );
+ ungetc(temp,sfd);
sf->mark_set_names[i] = SFDReadUTF7Str(sfd);
getint(sfd,&temp);
- sf->mark_sets[i] = malloc(temp+1); sf->mark_sets[i][temp] = '\0';
+ sf->mark_sets[i] = malloc(temp+1);
+ sf->mark_sets[i][temp] = '\0';
nlgetc(sfd); /* skip space */
fread(sf->mark_sets[i],1,temp,sfd);
}
@@ -8042,7 +8049,8 @@
int kernclassversion = 0;
int isv = tok[0]=='V';
int kcvoffset = (isv ? 10 : 9); //Offset to read kerning class version
- if (isdigit(tok[kcvoffset])) kernclassversion = tok[kcvoffset] - '0';
+ if (isdigit(tok[kcvoffset]))
+ kernclassversion = tok[kcvoffset] - '0';
int temp, classstart=1;
int old = (kernclassversion == 0);
@@ -8088,35 +8096,51 @@
for ( i=classstart; i<kc->first_cnt; ++i ) {
if (kernclassversion < 3) {
getint(sfd,&temp);
- kc->firsts[i] = malloc(temp+1); kc->firsts[i][temp] = '\0';
+ kc->firsts[i] = malloc(temp+1);
+ kc->firsts[i][temp] = '\0';
nlgetc(sfd); /* skip space */
fread(kc->firsts[i],1,temp,sfd);
} else {
getint(sfd,&kc->firsts_flags[i]);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\n' || ch == EOF) continue;
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
+ if (ch == '\n' || ch == EOF)
+ continue;
kc->firsts_names[i] = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\n' || ch == EOF) continue;
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
+ if (ch == '\n' || ch == EOF)
+ continue;
kc->firsts[i] = SFDReadUTF7Str(sfd);
if (kc->firsts[i] == NULL) kc->firsts[i] = copy(""); // In certain places, this must be defined.
- while ((ch=nlgetc(sfd)) == ' ' || ch == '\n'); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ' || ch == '\n');
+ ungetc(ch, sfd);
}
}
kc->seconds[0] = NULL;
for ( i=1; i<kc->second_cnt; ++i ) {
if (kernclassversion < 3) {
getint(sfd,&temp);
- kc->seconds[i] = malloc(temp+1); kc->seconds[i][temp] = '\0';
+ kc->seconds[i] = malloc(temp+1);
+ kc->seconds[i][temp] = '\0';
nlgetc(sfd); /* skip space */
fread(kc->seconds[i],1,temp,sfd);
} else {
getint(sfd,&temp);
kc->seconds_flags[i] = temp;
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\n' || ch == EOF) continue;
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
+ if (ch == '\n' || ch == EOF)
+ continue;
kc->seconds_names[i] = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd); if (ch == '\n' || ch == EOF) continue;
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
+ if (ch == '\n' || ch == EOF)
+ continue;
kc->seconds[i] = SFDReadUTF7Str(sfd);
if (kc->seconds[i] == NULL) kc->seconds[i] = copy(""); // In certain places, this must be defined.
- while ((ch=nlgetc(sfd)) == ' ' || ch == '\n'); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ' || ch == '\n');
+ ungetc(ch, sfd);
}
}
for ( i=0; i<kc->first_cnt*kc->second_cnt; ++i ) {
@@ -8173,39 +8197,50 @@
}
else if ( strmatch(tok,"Group:")==0 ) {
struct ff_glyphclasses *grouptmp = calloc(1, sizeof(struct ff_glyphclasses));
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
grouptmp->classname = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
grouptmp->glyphs = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' ' || ch == '\n'); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ' || ch == '\n');
+ ungetc(ch, sfd);
if (d->lastgroup != NULL) d->lastgroup->next = grouptmp; else sf->groups = grouptmp;
d->lastgroup = grouptmp;
}
else if ( strmatch(tok,"GroupKern:")==0 ) {
int temp = 0;
struct ff_rawoffsets *kerntmp = calloc(1, sizeof(struct ff_rawoffsets));
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
kerntmp->left = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
kerntmp->right = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
getint(sfd,&temp);
kerntmp->offset = temp;
- while ((ch=nlgetc(sfd)) == ' ' || ch == '\n'); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ' || ch == '\n');
+ ungetc(ch, sfd);
if (d->lastgroupkern != NULL) d->lastgroupkern->next = kerntmp; else sf->groupkerns = kerntmp;
d->lastgroupkern = kerntmp;
}
else if ( strmatch(tok,"GroupVKern:")==0 ) {
int temp = 0;
struct ff_rawoffsets *kerntmp = calloc(1, sizeof(struct ff_rawoffsets));
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
kerntmp->left = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
kerntmp->right = SFDReadUTF7Str(sfd);
- while ((ch=nlgetc(sfd)) == ' '); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ');
+ ungetc(ch, sfd);
getint(sfd,&temp);
kerntmp->offset = temp;
- while ((ch=nlgetc(sfd)) == ' ' || ch == '\n'); ungetc(ch, sfd);
+ while ((ch=nlgetc(sfd)) == ' ' || ch == '\n');
+ ungetc(ch, sfd);
if (d->lastgroupvkern != NULL) d->lastgroupvkern->next = kerntmp; else sf->groupvkerns = kerntmp;
d->lastgroupvkern = kerntmp;
}
@@ -8267,6 +8302,7 @@
//
return false;
}
+ free(kc);
return true;
}
@@ -8710,6 +8746,7 @@
else if ( lastnamedinstance !=NULL )
lastnamedinstance->names = names;
pushedbacktok = true;
+ free(names);
} else if ( strmatch(tok,"MMCDV:")==0 ) {
MMSet *mm = sf->mm;
if ( mm!=NULL )
@@ -8833,6 +8870,7 @@
if (sf->map == NULL) sf->map = EncMapNew(sf->glyphcnt,sf->glyphcnt,&custom);
SFDFixupUndoRefs(sf);
+ free(remap);
return( sf );
}
diff -urN fontforge-20170731.old/fontforge/sflayout.c fontforge-20170731/fontforge/sflayout.c
--- fontforge-20170731.old/fontforge/sflayout.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/sflayout.c 2018-09-23 14:50:31.576567408 +0530
@@ -1285,6 +1285,7 @@
LayoutInfo_Destroy(li);
if ( freeme!=NULL )
arrayfree(freeme);
+ free(li);
}
#include <stdlib.h>
@@ -1415,5 +1416,6 @@
}
LI_MetaChangeCleanup(li,start,end,width);
+ free(fl);
return( true );
}
diff -urN fontforge-20170731.old/fontforge/splinefont.c fontforge-20170731/fontforge/splinefont.c
--- fontforge-20170731.old/fontforge/splinefont.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/splinefont.c 2018-09-23 14:50:31.577567393 +0530
@@ -999,8 +999,10 @@
unlink(spuriousname); free(spuriousname);
} else
strippedname = Unarchive(strippedname,&archivedir);
- if ( strippedname==NULL )
- return NULL;
+ if ( strippedname==NULL ){
+ free(archivedir);
+ return NULL;
+ }
if ( strippedname!=fname && paren!=NULL ) {
fullname = malloc(strlen(strippedname)+strlen(paren)+1);
strcpy(fullname,strippedname);
@@ -1160,7 +1162,8 @@
checked = 'i';
sf = SFReadIkarus(fullname);
} /* Too hard to figure out a valid mark for a mac resource file */
- if ( file!=NULL ) fclose(file);
+ if ( file!=NULL )
+ fclose(file);
}
if ( sf!=NULL )
@@ -1280,7 +1283,9 @@
sf = NULL;
}
}
- if (fname != NULL && fname != filename) free(fname); fname = NULL;
+ if (fname != NULL && fname != filename)
+ free(fname);
+ fname = NULL;
return sf;
}
diff -urN fontforge-20170731.old/fontforge/splineoverlap.c fontforge-20170731/fontforge/splineoverlap.c
--- fontforge-20170731.old/fontforge/splineoverlap.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/splineoverlap.c 2018-09-23 14:50:31.577567393 +0530
@@ -494,6 +494,7 @@
}
current_pointer = &((*current_pointer)->next);
}
+ free(tmp_pointer);
return;
}
diff -urN fontforge-20170731.old/fontforge/splinesaveafm.c fontforge-20170731/fontforge/splinesaveafm.c
--- fontforge-20170731.old/fontforge/splinesaveafm.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/splinesaveafm.c 2018-09-23 14:55:32.054958121 +0530
@@ -1285,8 +1285,10 @@
ch = start[4]; start[4] = '\0';
unicode[u++] = strtol(start,&end,16);
start[4] = ch;
- if ( *end!='\0' )
-return( -1 );
+ if ( *end!='\0' ){
+ free(start);
+ return( -1 );
+ }
start += 4;
}
return( u );
@@ -3424,6 +3426,7 @@
free( italicindex );
} else
free( lkarray );
+ free(kerns);
return( !ferror(tfm));
}
diff -urN fontforge-20170731.old/fontforge/splinestroke.c fontforge-20170731/fontforge/splinestroke.c
--- fontforge-20170731.old/fontforge/splinestroke.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/splinestroke.c 2018-09-23 14:50:31.578567377 +0530
@@ -3847,6 +3847,7 @@
c.resolution = c.radius/3;
if (c.resolution == 0) {
ff_post_notice(_("Invalid stroke parameters"), _("Stroke resolution is zero"));
+ free(first);
return SplinePointListCopy(ss);
}
cur = SplineSets_Stroke(ss,&c,order2);
diff -urN fontforge-20170731.old/fontforge/splineutil.c fontforge-20170731/fontforge/splineutil.c
--- fontforge-20170731.old/fontforge/splineutil.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/splineutil.c 2018-09-23 14:50:31.579567361 +0530
@@ -224,7 +224,8 @@
next = spline->to->next; // Cache the location of the next spline.
SplinePointFree(spline->to); // Free the destination point.
SplineFree(spline); // Free the spline.
- if ( first==NULL ) first = spline; // We want to avoid repeating the circuit.
+ if ( first==NULL )
+ first = spline; // We want to avoid repeating the circuit.
}
// If the path is open or has no splines, free the starting point.
if ( spl->last!=spl->first || nonext )
@@ -262,7 +263,8 @@
next = spline->to->next;
SplinePointMDFree(sc,spline->to);
SplineFree(spline);
- if ( first==NULL ) first = spline;
+ if ( first==NULL )
+ first = spline;
}
if ( freefirst )
SplinePointMDFree(sc,spl->first);
@@ -1404,7 +1406,8 @@
last = cur;
i = j;
}
-return( head );
+ free(list);
+ return( head );
}
SplinePointList *SplinePointListCopy(const SplinePointList *base) {
diff -urN fontforge-20170731.old/fontforge/strlist.c fontforge-20170731/fontforge/strlist.c
--- fontforge-20170731.old/fontforge/strlist.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/strlist.c 2018-09-23 14:50:31.579567361 +0530
@@ -34,6 +34,7 @@
list->next = NULL;
list->str = str2;
}
+ free(str2);
return list;
}
diff -urN fontforge-20170731.old/fontforge/svg.c fontforge-20170731/fontforge/svg.c
--- fontforge-20170731.old/fontforge/svg.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/svg.c 2018-09-23 14:50:31.580567346 +0530
@@ -2634,8 +2634,11 @@
if ( name!=NULL ) {
int hide = xmlStrcmp(name,(xmlChar *) "none")==0;
xmlFree(name);
- if ( hide )
-return( NULL );
+ if ( hide ){
+ free(fill_colour_source);
+ free(stroke_colour_source);
+ return( NULL );
+ }
}
name = xmlGetProp(svg,(xmlChar *) "visibility");
if ( name!=NULL ) {
@@ -2772,7 +2775,9 @@
if ( !st.isvisible ) {
SvgStateFree(&st);
-return( NULL );
+ free(fill_colour_source);
+ free(stroke_colour_source);
+ return( NULL );
}
/* basic shapes */
@@ -2798,8 +2803,11 @@
return( eret );
} else
return( NULL );
- if ( head==NULL )
-return( NULL );
+ if ( head==NULL ){
+ free(fill_colour_source);
+ free(stroke_colour_source);
+ return( NULL );
+ }
SPLCategorizePoints(head);
@@ -3056,6 +3064,7 @@
}
free(u);
}
+ free(chars);
}
static char *SVGGetNames(SplineFont *sf,xmlChar *g,xmlChar *utf8,SplineChar **sc) {
diff -urN fontforge-20170731.old/fontforge/tottfaat.c fontforge-20170731/fontforge/tottfaat.c
--- fontforge-20170731.old/fontforge/tottfaat.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/tottfaat.c 2018-09-23 14:50:31.580567346 +0530
@@ -1483,6 +1483,7 @@
}
free(scripts);
}
+ free(sm);
return( features );
}
diff -urN fontforge-20170731.old/fontforge/tottf.c fontforge-20170731/fontforge/tottf.c
--- fontforge-20170731.old/fontforge/tottf.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/tottf.c 2018-09-23 14:50:31.581567330 +0530
@@ -4394,8 +4394,10 @@
(subheadcnt-i)*sizeof(struct subhead) + sizeof(uint16);
sub = tmpfile();
- if ( sub==NULL )
-return( NULL );
+ if ( sub==NULL ){
+ free(glyphs);
+ return( NULL );
+ }
putshort(sub,2); /* 8/16 format */
putshort(sub,0); /* Subtable length, we'll come back and fix this */
diff -urN fontforge-20170731.old/fontforge/tottfgpos.c fontforge-20170731/fontforge/tottfgpos.c
--- fontforge-20170731.old/fontforge/tottfgpos.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/tottfgpos.c 2018-09-23 14:54:53.300546119 +0530
@@ -452,8 +452,10 @@
++cnt;
}
}
- if ( cnt==0 )
-return( NULL );
+ if ( cnt==0 ){
+ free(array);
+ return( NULL );
+ }
if ( j==1 )
break;
array = malloc((cnt+1)*sizeof(SplineChar *));
@@ -583,13 +585,14 @@
// And we null-terminate.
glyphs[i] = NULL;
}
- for ( i=0; i<cnt-1; ++i )
+ for ( i=0; i<cnt-1; ++i ){
if (glyphs[i]->ttf_glyph==glyphs[i+1]->ttf_glyph) {
// fprintf(stderr, "Duplicate glyph.\n");
memmove(glyphs+i, glyphs+i+1, (cnt-i)*sizeof(SplineChar *));
--cnt;
}
- glyphs[cnt] = NULL;
+ }
+ glyphs[cnt] = NULL;
return( glyphs );
}
@@ -3476,8 +3479,10 @@
glyphs = malloc((lcnt+1)*sizeof(SplineChar *));
glyphs[lcnt] = NULL;
}
- if ( !needsclass && lcnt==0 && sf->mark_class_cnt==0 && sf->mark_set_cnt==0 )
-return; /* No anchor positioning, no ligature carets */
+ if ( !needsclass && lcnt==0 && sf->mark_class_cnt==0 && sf->mark_set_cnt==0 ){
+ free(glyphs);
+ return; /* No anchor positioning, no ligature carets */
+ }
at->gdef = tmpfile();
if ( sf->mark_set_cnt==0 ) {
diff -urN fontforge-20170731.old/fontforge/ttfinstrs.c fontforge-20170731/fontforge/ttfinstrs.c
--- fontforge-20170731.old/fontforge/ttfinstrs.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/ttfinstrs.c 2018-09-23 14:50:31.582567314 +0530
@@ -309,7 +309,8 @@
val = strtol(pt,&end,0);
if ( val>32767 || val<-32768 ) {
IVError(iv,_("A value must be between [-32768,32767]"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
pt = end;
@@ -317,14 +318,16 @@
if ( *pt == '@' ) { /* a delta control byte */
if ( val>8 || val<-8 || val==0 ) {
IVError(iv,_("A value must be between [-8,-1] or [1,8]"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
pt++;
if ( !isdigit( *pt ) ) {
IVError(iv,_("Number expected"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
temp = val;
@@ -332,7 +335,8 @@
if ( val>15 || val<0 ) {
IVError(iv,_("A value must be between [0,15]"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
val *= 16;
@@ -348,14 +352,16 @@
while ( *pt==' ' || *pt=='\t' ) ++pt;
if ( *pt!='(' ) {
IVError(iv,_("Missing left parenthesis in command to get a cvt index"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
temp = strtol(pt+1,&end,0);
pt = end;
while ( *pt==' ' || *pt=='\t' ) ++pt;
if ( *pt!=')' ) {
IVError(iv,_("Missing right paren in command to get a cvt index"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
numberstack[npos++] = TTF__getcvtval(sf,temp);
++pt;
@@ -396,7 +402,8 @@
}
if ( nread<npos && push_left==0 && (*pt=='\r' || *pt=='\n' || *pt=='\0')) {
IVError(iv,_("Unexpected number"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
if ( *pt=='\r' || *pt=='\n' || *pt=='\0' )
continue;
@@ -446,11 +453,13 @@
while ( *bend==' ' || *bend=='\t' ) ++bend;
if ( *bend!=']' ) {
IVError(iv,_("Missing right bracket in command (or bad binary value in bracket)"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
if ( val>=32 ) {
IVError(iv,_("Bracketted value is too large"),pt-text);
-return( NULL );
+ free(instrs);
+ return( NULL );
}
i += val;
}
diff -urN fontforge-20170731.old/fontforge/ttfspecial.c fontforge-20170731/fontforge/ttfspecial.c
--- fontforge-20170731.old/fontforge/ttfspecial.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/ttfspecial.c 2018-09-23 14:54:21.159033774 +0530
@@ -1356,6 +1356,7 @@
}
}
free(contours);
+ free(cur);
}
static void pfed_readguidelines(FILE *ttf,struct ttfinfo *info,uint32 base) {
diff -urN fontforge-20170731.old/fontforge/ufo.c fontforge-20170731/fontforge/ufo.c
--- fontforge-20170731.old/fontforge/ufo.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforge/ufo.c 2018-09-23 14:50:31.583567299 +0530
@@ -2513,7 +2513,18 @@
}
lastref = r;
}
- if (xs) free(xs); if (ys) free(ys); if (xys) free(xys); if (yxs) free(yxs); if (xo) free(xo); if (yo) free(yo);
+ if (xs)
+ free(xs);
+ if (ys)
+ free(ys);
+ if (xys)
+ free(xys);
+ if (yxs)
+ free(yxs);
+ if (xo)
+ free(xo);
+ if (yo)
+ free(yo);
} else if ( xmlStrcmp(contour->name,(const xmlChar *) "contour")==0 ) {
xmlNodePtr npoints;
@@ -4065,12 +4076,12 @@
strncmp(sf->names->names[ttf_version],"Version ",8)==0 )
sf->version = copy(sf->names->names[ttf_version]+8);
- char * layercontentsname = buildname(basedir,"layercontents.plist");
- char ** layernames = NULL;
- if (layercontentsname == NULL) {
+ char * layercontentsname = buildname(basedir,"layercontents.plist");
+ char ** layernames = NULL;
+ if (layercontentsname == NULL) {
switch_to_old_locale(&tmplocale, &oldlocale); // Switch to the cached locale.
return( NULL );
- } else if ( GFileExists(layercontentsname)) {
+ } else if ( GFileExists(layercontentsname)) {
xmlDocPtr layercontentsdoc = NULL;
xmlNodePtr layercontentsplist = NULL;
xmlNodePtr layercontentsdict = NULL;
diff -urN fontforge-20170731.old/fontforgeexe/alignment.c fontforge-20170731/fontforgeexe/alignment.c
--- fontforge-20170731.old/fontforgeexe/alignment.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/alignment.c 2018-09-23 14:50:31.583567299 +0530
@@ -126,8 +126,10 @@
}
/* we need at least three regions to space things out */
- if ( rcnt<3 )
+ if ( rcnt<3 ){
+ free(regions);
return;
+ }
/* Now should I allow equal spaces between regions, or spaces between */
/* region mid-points? I think spaces between regions */
diff -urN fontforge-20170731.old/fontforgeexe/charinfo.c fontforge-20170731/fontforgeexe/charinfo.c
--- fontforge-20170731.old/fontforgeexe/charinfo.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/charinfo.c 2018-09-23 14:50:31.584567283 +0530
@@ -3008,6 +3008,7 @@
for ( j=0; j<i; ++j )
BDFCharFree(others[j]);
free(others);
+ free(me);
return( NULL );
}
others[i] = Rasterize(othersc,def_layer);
@@ -3263,6 +3264,7 @@
for ( i=0; i<extracnt; ++i )
BDFCharFree(extras[i]);
free(extras);
+ free(me);
return( NULL );
}
diff -urN fontforge-20170731.old/fontforgeexe/charview.c fontforge-20170731/fontforgeexe/charview.c
--- fontforge-20170731.old/fontforgeexe/charview.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/charview.c 2018-09-23 14:50:31.585567268 +0530
@@ -4437,7 +4437,10 @@
sign = dx*dy<0?-1:1;
fake->u.mouse = event->u.mouse;
- if ( dx<0 ) dx = -dx; if ( dy<0 ) dy = -dy;
+ if ( dx<0 )
+ dx = -dx;
+ if ( dy<0 )
+ dy = -dy;
if ( dy >= 2*dx ) {
cv->p.x = fake->u.mouse.x = basex;
cv->p.cx = basetruex ;
@@ -4726,6 +4729,7 @@
{
GGadgetSetTitle( cv->charselector, p );
}
+ free(srctxt);
}
@@ -5328,7 +5332,10 @@
int sign = dx*dy<0?-1:1;
double aspect = 1.0;
- if ( dx<0 ) dx = -dx; if ( dy<0 ) dy = -dy;
+ if ( dx<0 )
+ dx = -dx;
+ if ( dy<0 )
+ dy = -dy;
if ( cv->p.img!=NULL && cv->p.img->bb.minx!=cv->p.img->bb.maxx )
aspect = (cv->p.img->bb.maxy - cv->p.img->bb.miny) / (cv->p.img->bb.maxx - cv->p.img->bb.minx);
else if ( cv->p.ref!=NULL && cv->p.ref->bb.minx!=cv->p.ref->bb.maxx )
@@ -7487,8 +7494,10 @@
e.u.control.subtype = et_textchanged;
e.u.control.u.tf_changed.from_pulldown = 0;
CV_OnCharSelectorTextChanged( cv->charselector, &e );
+ free(txt);
return;
}
+ free(txt);
}
if ( mid == MID_Next ) {
@@ -12810,6 +12819,7 @@
}
}
}
+ free(wll);
}
free(txt);
diff -urN fontforge-20170731.old/fontforgeexe/contextchain.c fontforge-20170731/fontforgeexe/contextchain.c
--- fontforge-20170731.old/fontforgeexe/contextchain.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/contextchain.c 2018-09-23 14:50:31.586567252 +0530
@@ -641,6 +641,7 @@
(&r->u.class.nclasses)[which] = malloc(any*sizeof(uint16));
}
}
+ free(pt);
return( true );
}
diff -urN fontforge-20170731.old/fontforgeexe/cvgetinfo.c fontforge-20170731/fontforgeexe/cvgetinfo.c
--- fontforge-20170731.old/fontforgeexe/cvgetinfo.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/cvgetinfo.c 2018-09-23 14:50:31.586567252 +0530
@@ -1059,6 +1059,7 @@
ti = AnchorClassesLList(sf),false);
for ( j=0; ti[j]->text!=NULL && ti[j]->userdata!=ac; ++j )
GGadgetSelectOneListItem(GWidgetGetControl(ci->gw,CID_NameList),j);
+ free(name);
return( true );
}
@@ -3903,8 +3904,11 @@
}
++k;
} while ( k<_sf->subfontcnt );
- if ( tot==0 )
+ if ( tot==0 ){
+ free(deps);
+ free(depsc);
return;
+ }
if ( j==0 ) {
deps = calloc(tot+1,sizeof(char *));
depsc = malloc(tot*sizeof(SplineChar *));
diff -urN fontforge-20170731.old/fontforgeexe/cvimportdlg.c fontforge-20170731/fontforgeexe/cvimportdlg.c
--- fontforge-20170731.old/fontforgeexe/cvimportdlg.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/cvimportdlg.c 2018-09-23 14:50:31.587567236 +0530
@@ -427,8 +427,10 @@
GGadget *tf;
GFileChooserGetChildren(d->gfc,NULL,NULL,&tf);
- if ( *_GGadgetGetTitle(tf)=='\0' )
+ if ( *_GGadgetGetTitle(tf)=='\0' ){
+ free(temp);
return( true );
+ }
GDrawSetCursor(GGadgetGetWindow(g),ct_watch);
if ( d->fv!=NULL )
flast_format = pos;
diff -urN fontforge-20170731.old/fontforgeexe/cvpalettes.c fontforge-20170731/fontforgeexe/cvpalettes.c
--- fontforge-20170731.old/fontforgeexe/cvpalettes.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/cvpalettes.c 2018-09-23 14:50:31.587567236 +0530
@@ -2432,6 +2432,7 @@
layerinfo.rename_active = 0;
CVInfoDrawText(cv,cv->gw);
+ free(str);
}
}
diff -urN fontforge-20170731.old/fontforgeexe/displayfonts.c fontforge-20170731/fontforgeexe/displayfonts.c
--- fontforge-20170731.old/fontforgeexe/displayfonts.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/displayfonts.c 2018-09-23 14:50:31.588567221 +0530
@@ -138,6 +138,7 @@
float pw,ph, scale;
if ( sscanf(cret,"%gx%g",&pw,&ph)!=2 ) {
IError("Bad Pagesize must be a known name or <num>x<num><units>\nWhere <units> is one of pt (points), mm, cm, in" );
+ free(cret);
return( true );
}
pt = cret+strlen(cret)-1;
@@ -152,6 +153,7 @@
scale = 1;
else {
IError("Bad Pagesize units are unknown\nMust be one of pt (points), mm, cm, in" );
+ free(pt);
return( true );
}
pgwidth = pw*scale; pgheight = ph*scale;
@@ -1431,6 +1433,7 @@
feats[cnt] = 0;
/* These will be ordered because the list widget will do that */
SFTFSetFeatures(GWidgetGetControl(di->gw,CID_SampleText),-1,-1,feats);
+ free(feats);
}
return( true );
}
diff -urN fontforge-20170731.old/fontforgeexe/fontinfo.c fontforge-20170731/fontforgeexe/fontinfo.c
--- fontforge-20170731.old/fontforgeexe/fontinfo.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/fontinfo.c 2018-09-23 14:50:31.589567205 +0530
@@ -3752,6 +3752,7 @@
}
}
}
+ free(changed);
}
static void StoreTTFNames(struct gfi_data *d) {
diff -urN fontforge-20170731.old/fontforgeexe/fontview.c fontforge-20170731/fontforgeexe/fontview.c
--- fontforge-20170731.old/fontforgeexe/fontview.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/fontview.c 2018-09-23 14:50:31.590567190 +0530
@@ -582,6 +582,7 @@
GGadgetSetTitle8(fc,newname);
save_to_dir = *_s2d = s2d;
SavePrefs(true);
+ free(oldname);
}
return( true );
}
@@ -3741,12 +3742,15 @@
free(filename);
if ( new==NULL )
return;
- if ( new->fv == &fv->b ) /* Already part of us */
+ if ( new->fv == &fv->b ) { /* Already part of us */
+ free(new);
return;
+ }
if ( new->fv != NULL ) {
if ( ((FontView *) (new->fv))->gw!=NULL )
GDrawRaise( ((FontView *) (new->fv))->gw);
ff_post_error(_("Please close font"),_("Please close %s before inserting it into a CID font"),new->origname);
+ free(new);
return;
}
EncMapFree(new->map);
@@ -4978,9 +4982,11 @@
nl = NameListByName(namelists[ret]);
if ( nl==NULL ) {
IError("Couldn't find namelist");
+ free(namelists);
return;
} else if ( nl!=NULL && nl->uses_unicode && !allow_utf8_glyphnames) {
ff_post_error(_("Namelist contains non-ASCII names"),_("Glyph names should be limited to characters in the ASCII character set, but there are names in this namelist which use characters outside that range."));
+ free(namelists);
return;
}
SFRenameGlyphsToNamelist(fv->b.sf,nl);
@@ -6699,7 +6705,9 @@
msg = xasprintf ( "%u 0x%x U+%04X \"%.25s\" %.100s",
localenc, localenc, upos,
(sc->name == NULL) ? "" : sc->name, uniname );
- if ( uniname != NULL ) free( uniname ); uniname = NULL;
+ if ( uniname != NULL )
+ free( uniname );
+ uniname = NULL;
/* annotation */
char *uniannot = unicode_annot( upos );
@@ -8129,6 +8137,7 @@
free(repr);
*rpt++ = ' ';
}
+ free(repr);
}
}
if ( k==0 )
diff -urN fontforge-20170731.old/fontforgeexe/fvfontsdlg.c fontforge-20170731/fontforgeexe/fvfontsdlg.c
--- fontforge-20170731.old/fontforgeexe/fvfontsdlg.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/fvfontsdlg.c 2018-09-23 14:50:31.590567190 +0530
@@ -73,6 +73,7 @@
file = fpt+2;
} while ( fpt!=NULL );
free(filename);
+ free(sf);
}
GTextInfo *BuildFontList(FontView *except) {
@@ -285,6 +286,7 @@
if ( sf==NULL )
return;
FontViewCreate(InterpolateFont(fv->b.sf,sf,amount,fv->b.map->enc),false);
+ free(sf);
}
#define CID_Amount 1000
diff -urN fontforge-20170731.old/fontforgeexe/histograms.c fontforge-20170731/fontforgeexe/histograms.c
--- fontforge-20170731.old/fontforgeexe/histograms.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/histograms.c 2018-09-23 14:50:31.590567190 +0530
@@ -573,8 +573,11 @@
ret2 = GGadgetGetTitle(GWidgetGetControl(hist->gw,CID_SecondaryVal));
hist->done = true;
if ( (*ret1=='\0' || uc_strcmp(ret1,"[]")==0 ) &&
- (*ret2=='\0' || uc_strcmp(ret2,"[]")==0 ) && p==NULL )
+ (*ret2=='\0' || uc_strcmp(ret2,"[]")==0 ) && p==NULL ){
+ free(ret1);
+ free(ret2);
return;
+ }
if ( p==NULL ) {
hist->sf->private = p = calloc(1,sizeof(struct psdict));
p->cnt = 10;
@@ -583,6 +586,8 @@
}
PSDictChangeEntry(p,primary,temp=cu_copy(ret1)); free(temp);
PSDictChangeEntry(p,secondary,temp=cu_copy(ret2)); free(temp);
+ free(ret1);
+ free(ret2);
}
static int leftside_e_h(GWindow gw, GEvent *event) {
diff -urN fontforge-20170731.old/fontforgeexe/kernclass.c fontforge-20170731/fontforgeexe/kernclass.c
--- fontforge-20170731.old/fontforgeexe/kernclass.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/kernclass.c 2018-09-23 14:50:31.591567174 +0530
@@ -1345,6 +1345,7 @@
KCD_VShow(kcd,i);
else
KCD_HShow(kcd,i);
+ free(name);
return( true );
}
if ( *pt=='(' ) {
@@ -1358,7 +1359,9 @@
/* Otherwise deselect everything */
if ( nlen!=0 )
GMatrixEditActivateRowCol(list,-1,-1);
+ free(name);
}
+
return( true );
}
@@ -2235,6 +2238,7 @@
GDrawRequestExpose(kcd->subw,NULL,false);
+ free(other);
return( new );
}
diff -urN fontforge-20170731.old/fontforgeexe/lookupui.c fontforge-20170731/fontforgeexe/lookupui.c
--- fontforge-20170731.old/fontforgeexe/lookupui.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/lookupui.c 2018-09-23 14:54:04.668283976 +0530
@@ -2779,16 +2779,23 @@
char *suffix = GGadgetGetTitle8(GWidgetGetControl(pstkd->gw,CID_Suffix));
SplineChar *alt, *sc;
- if ( col!=0 || !wasnew || psts[row*cols+0].u.md_str==NULL )
+ if ( col!=0 || !wasnew || psts[row*cols+0].u.md_str==NULL ){
+ free(suffix);
return;
- if ( *suffix=='\0' || ( suffix[0]=='.' && suffix[1]=='\0' ))
+ }
+ if ( *suffix=='\0' || ( suffix[0]=='.' && suffix[1]=='\0' )){
+ free(suffix);
return;
+ }
sc = SFGetChar(pstkd->sf,-1,psts[row*cols+0].u.md_str);
- if ( sc==NULL )
+ if ( sc==NULL ){
+ free(suffix);
return;
+ }
alt = SuffixCheck(sc,suffix);
if ( alt!=NULL )
psts[row*cols+1].u.md_str = copy(alt->name);
+ free(suffix);
}
static void PSTKD_FinishBoundsEdit(GGadget *g, int row, int col, int wasnew) {
@@ -3403,8 +3410,8 @@
if ( *suffix!='\0' && ( suffix[0]!='.' || suffix[1]!='\0' )) {
free(pstkd->sub->suffix);
pstkd->sub->suffix = ( *suffix=='.' ) ? copy(suffix+1): copy(suffix);
- free(suffix);
}
+ free(suffix);
}
static int PSTKD_PopulateWithSuffix(GGadget *g, GEvent *e) {
@@ -3953,6 +3960,8 @@
error2SFDTrimUndoOldToNew: fclose(nf);
error1SFDTrimUndoOldToNew: fclose(retf);
error0SFDTrimUndoOldToNew:
+ free(nglyph);
+ free(oglyph);
return 0;
}
@@ -4229,9 +4238,11 @@
dlist_pushfront( (struct dlistnode **)&sf->undoes, (struct dlistnode *)undo );
}
// printf("we now have %d splinefont level undoes\n", dlist_size((struct dlistnode **)&sf->undoes));
+ free(str);
}
pstkd->done = true;
+ free(oldsfd);
}
return( true );
}
@@ -6069,6 +6080,7 @@
while ( (lang = StrNextLang(&pt))!=0 ) {
if ( lang==0xffffffff ) {
ff_post_error(_("Invalid language"), _("Please specify a comma separated list of 4 letter opentype language tags"));
+ free(langs);
return( true );
}
}
diff -urN fontforge-20170731.old/fontforgeexe/macencui.c fontforge-20170731/fontforgeexe/macencui.c
--- fontforge-20170731.old/fontforgeexe/macencui.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/macencui.c 2018-09-23 14:50:31.592567158 +0530
@@ -425,6 +425,7 @@
nd->done = true;
}
}
+ free(temp);
return( true );
}
diff -urN fontforge-20170731.old/fontforgeexe/metricsview.c fontforge-20170731/fontforgeexe/metricsview.c
--- fontforge-20170731.old/fontforgeexe/metricsview.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/metricsview.c 2018-09-23 14:50:31.592567158 +0530
@@ -1970,8 +1970,11 @@
if ( *pt!=mv->chars[i]->unicodeenc &&
!MVOddMatch(mv,*pt,mv->chars[i]))
break;
- if ( i==mv->clen && *pt=='\0' )
-return; /* Nothing changed */
+ if ( i==mv->clen && *pt=='\0' ){
+ free(pt);
+return;
+ }
+ /* Nothing changed */
for ( ept=ret+u_strlen(ret)-1, ei=mv->clen-1; ; --ei, --ept )
if ( ei<0 || ept<ret || (*ept!=mv->chars[ei]->unicodeenc &&
!MVOddMatch(mv,*ept,mv->chars[ei]))) {
@@ -2046,6 +2049,7 @@
selectUserChosenWordListGlyphs( mv, wll );
GDrawRequestExpose(mv->v,NULL,false);
+ free(pt);
}
GTextInfo mv_text_init[] = {
diff -urN fontforge-20170731.old/fontforgeexe/mmdlg.c fontforge-20170731/fontforgeexe/mmdlg.c
--- fontforge-20170731.old/fontforgeexe/mmdlg.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/mmdlg.c 2018-09-23 14:50:31.593567143 +0530
@@ -1980,6 +1980,7 @@
enc = default_encoding;
FVReencode((FontViewBase *) fv,enc);
mmw->done = true;
+ free(setto);
}
static void MMW_DoNext(MMW *mmw) {
@@ -2374,17 +2375,19 @@
if ( ti!=NULL && ti->userdata == (void *) -1 ) {
temp = GetPostScriptFontName(NULL,false);
if ( temp==NULL )
-return(true);
+ return(true);
sf = LoadSplineFont(temp,0);
free(temp); temp = NULL;
if ( sf==NULL )
-return(true);
+ return(true);
if ( sf->cidmaster!=NULL || sf->subfonts!=0 ) {
ff_post_error(_("Bad Multiple Master Font"),_("CID keyed fonts may not be a master design of a multiple master font"));
-return(true);
+ free(sf);
+ return(true);
} else if ( sf->mm!=NULL ) {
ff_post_error(_("Bad Multiple Master Font"),_("CID keyed fonts may not be a master design of a multiple master font"));
-return(true);
+ free(sf);
+ return(true);
}
if ( sf->fv==NULL ) {
if ( mmw->lcnt>=mmw->lmax ) {
@@ -2406,6 +2409,7 @@
GGadgetSetTitle(g,ut = uc_copy(sf->fontname));
free(ut);
}
+ free(sf);
}
return( true );
}
diff -urN fontforge-20170731.old/fontforgeexe/prefs.c fontforge-20170731/fontforgeexe/prefs.c
--- fontforge-20170731.old/fontforgeexe/prefs.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/prefs.c 2018-09-23 14:50:31.593567143 +0530
@@ -2380,6 +2380,7 @@
hvarray[si++] = &pgcd[gc-1];
hvarray[si++] = GCD_ColSpan; hvarray[si++] = GCD_ColSpan;
y += 28;
+ free(nlnames);
} break;
case pr_string: case pr_file:
if ( pl->set==SetAutoTraceArgs || ((char **) pl->val)==&mf_args )
@@ -2955,6 +2956,7 @@
hvarray[si++] = &pgcd[gc-1];
hvarray[si++] = GCD_ColSpan; hvarray[si++] = GCD_ColSpan;
y += 28;
+ free(nlnames);
} break;
case pr_string: case pr_file:
if ( pl->set==SetAutoTraceArgs || ((char **) pl->val)==&mf_args )
diff -urN fontforge-20170731.old/fontforgeexe/savefontdlg.c fontforge-20170731/fontforgeexe/savefontdlg.c
--- fontforge-20170731.old/fontforgeexe/savefontdlg.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/savefontdlg.c 2018-09-23 14:50:31.594567127 +0530
@@ -1426,8 +1426,10 @@
oldbitmapstate = GGadgetGetFirstListSelectedItem(d->bmptype);
if ( oldbitmapstate!=bf_none )
sizes = ParseBitmapSizes(d->bmpsizes,_("Pixel List"),&err);
- if ( err )
+ if ( err ){
+ free(temp);
return;
+ }
if ( oldbitmapstate==bf_nfntmacbin && oldformatstate!=ff_pfbmacbin && !nfnt_warned ) {
nfnt_warned = true;
ff_post_notice(_("The 'NFNT' bitmap format is obsolete"),_("The 'NFNT' bitmap format is not used under OS/X (though you still need to create a (useless) bitmap font if you are saving a type1 PostScript resource)"));
@@ -1484,7 +1486,9 @@
d->done = true;
d->ret = false;
SFValidationWindow(d->sf,layer,oldformatstate);
-return;
+ free(sizes);
+ free(temp);
+ return;
}
/* Ok... they want to proceed */
}
@@ -1581,6 +1585,7 @@
free(temp);
d->done = !err;
d->ret = !err;
+ free(cur);
}
static void GFD_doesnt(GIOControl *gio) {
@@ -2109,6 +2114,7 @@
}
if ( MacStyleCode(sf,NULL)!=0 || familycnt<=1 || sf->multilayer ) {
ff_post_error(_("Bad Mac Family"),_("To generate a Mac family file, the current font must have plain (Normal, Regular, etc.) style, and there must be other open fonts with the same family name."));
+ free(familysfs);
return( 0 );
} else if ( dup ) {
MacStyleCode(dup,&psstyle);
diff -urN fontforge-20170731.old/fontforgeexe/scstylesui.c fontforge-20170731/fontforgeexe/scstylesui.c
--- fontforge-20170731.old/fontforgeexe/scstylesui.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/scstylesui.c 2018-09-23 14:50:31.594567127 +0530
@@ -2323,6 +2323,7 @@
FVTrans((FontViewBase *) fv,sc,transform,NULL,fvt_dontmovewidth);
}
}
+ free(ret);
}
diff -urN fontforge-20170731.old/fontforgeexe/sftextfield.c fontforge-20170731/fontforgeexe/sftextfield.c
--- fontforge-20170731.old/fontforgeexe/sftextfield.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/sftextfield.c 2018-09-23 14:50:31.594567127 +0530
@@ -702,8 +702,10 @@
}
for ( cnt=0; scriptlangs[cnt]!=NULL; ++cnt );
i = ff_choose(_("Text from script"),(const char **) scriptlangs,cnt,0,_("Insert random text in the specified script"));
- if ( i==-1 )
+ if ( i==-1) {
+ free(freq);
return;
+ }
pos = strlen(scriptlangs[i])-10;
script = (scriptlangs[i][pos+0]<<24) |
(scriptlangs[i][pos+1]<<16) |
@@ -2303,6 +2305,7 @@
}
SFTFMetaChangeCleanup(st,start,end);
+ free(fl);
return( true );
}
@@ -2323,6 +2326,7 @@
}
SFTFMetaChangeCleanup(st,start,end);
+ free(fl);
return( true );
}
@@ -2345,6 +2349,7 @@
}
SFTFMetaChangeCleanup(st,start,end);
+ free(fl);
return( true );
}
@@ -2365,6 +2370,7 @@
}
SFTFMetaChangeCleanup(st,start,end);
+ free(fl);
return( true );
}
@@ -2385,6 +2391,7 @@
}
SFTFMetaChangeCleanup(st,start,end);
+ free(fl);
return( true );
}
@@ -2401,6 +2408,7 @@
}
SFTFMetaChangeCleanup(st,start,end);
+ free(fl);
return( true );
}
diff -urN fontforge-20170731.old/fontforgeexe/statemachine.c fontforge-20170731/fontforgeexe/statemachine.c
--- fontforge-20170731.old/fontforgeexe/statemachine.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/statemachine.c 2018-09-23 14:50:31.595567112 +0530
@@ -438,6 +438,7 @@
/* Show changes in main window */
GDrawRequestExpose(smd->gw,NULL,false);
+ free(ret8);
return( true );
}
diff -urN fontforge-20170731.old/fontforgeexe/wordlistparser.c fontforge-20170731/fontforgeexe/wordlistparser.c
--- fontforge-20170731.old/fontforgeexe/wordlistparser.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/fontforgeexe/wordlistparser.c 2018-09-23 14:50:31.595567112 +0530
@@ -799,7 +799,8 @@
if( element_selected )
uc_strcat( ret, "]" );
}
-
+
+ free(wll);
return ret;
}
@@ -841,6 +842,7 @@
{
// we can't go back manually!
u_strcpy( ret, original_data );
+ free(wll);
return ret;
}
}
@@ -862,6 +864,7 @@
uc_strcat( ret, "]" );
}
+ free(wll);
return ret;
}
diff -urN fontforge-20170731.old/gdraw/gimageclut.c fontforge-20170731/gdraw/gimageclut.c
--- fontforge-20170731.old/gdraw/gimageclut.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gimageclut.c 2018-09-23 14:50:31.595567112 +0530
@@ -460,9 +460,10 @@
if ( clut==NULL )
clut = malloc(sizeof(GClut));
- if ( clutmax<2 || clut==NULL )
+ if ( clutmax<2 || clut==NULL ){
+ free(clut);
return( 0 );
-
+ }
clut->clut_len = 0; clut->is_grey = false;
if ( clutmax>256 ) clutmax = 256;
@@ -555,14 +556,24 @@
if ( test->next==NULL )
return( (GCol *) test );
- if (( best = (r-test->red))<0 ) best = -best;
- if (( t = (g-test->green))<0 ) t = -t; best += t;
- if (( t = (b-test->blue))<0 ) t = -t; best += t;
+ if (( best = (r-test->red))<0 )
+ best = -best;
+ if (( t = (g-test->green))<0 )
+ t = -t;
+ best += t;
+ if (( t = (b-test->blue))<0 )
+ t = -t;
+ best += t;
bestcol = test;
for ( test=test->next; test!=NULL; test = test->next ) {
- if (( val = (r-test->red))<0 ) val = -val;
- if (( t = (g-test->green))<0 ) t = -t; val += t;
- if (( t = (b-test->blue))<0 ) t = -t; val += t;
+ if (( val = (r-test->red))<0 )
+ val = -val;
+ if (( t = (g-test->green))<0 )
+ t = -t;
+ val += t;
+ if (( t = (b-test->blue))<0 )
+ t = -t;
+ val += t;
if ( val<best ) {
val = best;
bestcol = test;
@@ -612,14 +623,24 @@
if ( test->next==NULL && this->cols[1]==NULL )
return( (GCol *) test );
- if (( best = (r-test->red))<0 ) best = -best;
- if (( t = (g-test->green))<0 ) t = -t; best += t;
- if (( t = (b-test->blue))<0 ) t = -t; best += t;
+ if (( best = (r-test->red))<0 )
+ best = -best;
+ if (( t = (g-test->green))<0 )
+ t = -t;
+ best += t;
+ if (( t = (b-test->blue))<0 )
+ t = -t;
+ best += t;
bestcol = test;
for ( test=test->next; test!=NULL; test = test->next ) {
- if (( val = (r-test->red))<0 ) val = -val;
- if (( t = (g-test->green))<0 ) t = -t; val += t;
- if (( t = (b-test->blue))<0 ) t = -t; val += t;
+ if (( val = (r-test->red))<0 )
+ val = -val;
+ if (( t = (g-test->green))<0 )
+ t = -t;
+ val += t;
+ if (( t = (b-test->blue))<0 )
+ t = -t;
+ val += t;
if ( val<best ) {
val = best;
bestcol = test;
@@ -627,9 +648,14 @@
}
for ( test=this->cols[1]; test!=NULL; test = test->next ) {
- if (( val = (r-test->red))<0 ) val = -val;
- if (( t = (g-test->green))<0 ) t = -t; val += t;
- if (( t = (b-test->blue))<0 ) t = -t; val += t;
+ if (( val = (r-test->red))<0 )
+ val = -val;
+ if (( t = (g-test->green))<0 )
+ t = -t;
+ val += t;
+ if (( t = (b-test->blue))<0 )
+ t = -t;
+ val += t;
if ( val<best ) {
val = best;
bestcol = test;
@@ -656,18 +682,28 @@
return( old );
bestoff = 3*255;
for ( test=test; test!=NULL; test = test->next ) {
- if ( (off = (r-test->red))<0 ) off = -off;
- if ( (t = (g-test->green))<0 ) t = -t; off +=t;
- if ( (b = (g-test->blue))<0 ) t = -t; off +=t;
+ if ( (off = (r-test->red))<0 )
+ off = -off;
+ if ( (t = (g-test->green))<0 )
+ t = -t;
+ off +=t;
+ if ( (b = (g-test->blue))<0 )
+ t = -t;
+ off +=t;
if ( off<bestoff ) {
bestoff = off;
best = test;
}
}
if ( old!=NULL ) {
- if ( (off = (r-old->red))<0 ) off = -off;
- if ( (t = (g-old->green))<0 ) t = -t; off +=t;
- if ( (b = (g-old->blue))<0 ) t = -t; off +=t;
+ if ( (off = (r-old->red))<0 )
+ off = -off;
+ if ( (t = (g-old->green))<0 )
+ t = -t;
+ off +=t;
+ if ( (b = (g-old->blue))<0 )
+ t = -t;
+ off +=t;
if ( off<bestoff ) {
bestoff = off;
best = old;
diff -urN fontforge-20170731.old/gdraw/gimagecvt.c fontforge-20170731/gdraw/gimagecvt.c
--- fontforge-20170731.old/gdraw/gimagecvt.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gimagecvt.c 2018-09-23 14:50:31.596567096 +0530
@@ -978,6 +978,11 @@
}}
if ( oldrev!=rev )
GClut_RevCMapFree(rev);
+ free(blue_dith);
+ free(green_dith);
+ free(red_dith);
+ free(hor);
+ free(vert);
}
GImage *GImageResize32(GImage *from, GRect *src, int width, int height, Color trans) {
diff -urN fontforge-20170731.old/gdraw/gmatrixedit.c fontforge-20170731/gdraw/gmatrixedit.c
--- fontforge-20170731.old/gdraw/gmatrixedit.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gmatrixedit.c 2018-09-23 14:50:31.596567096 +0530
@@ -40,7 +40,7 @@
static GBox gmatrixedit_box = GBOX_EMPTY; /* Don't initialize here */
static GBox gmatrixedit_button_box = GBOX_EMPTY; /* Don't initialize here */
-static FontInstance *gmatrixedit_font = NULL, *gmatrixedit_titfont = NULL;
+static FontInstance *gmatrixedit_font = NULL, *gmatrixedit_titfont = NULL, *gtitfont = NULL;
static Color gmatrixedit_title_bg = 0x808080, gmatrixedit_title_fg = 0x000000, gmatrixedit_title_divider = 0xffffff;
static Color gmatrixedit_rules = 0x000000;
static Color gmatrixedit_frozencol = 0xff0000,
@@ -115,7 +115,8 @@
GDrawDecomposeFont(gmatrixedit_font,&rq);
rq.point_size = (rq.point_size>=12) ? rq.point_size-2 : rq.point_size>=10 ? rq.point_size-1 : rq.point_size;
rq.weight = 700;
- gmatrixedit_titfont = GResourceFindFont("GMatrixEdit.TitleFont",GDrawInstanciateFont(NULL,&rq));
+ gtitfont = GDrawInstanciateFont(NULL,&rq);
+ gmatrixedit_titfont = GResourceFindFont("GMatrixEdit.TitleFont",gtitfont);
gmatrixedit_title_bg = GResourceFindColor("GMatrixEdit.TitleBG",gmatrixedit_title_bg);
gmatrixedit_title_fg = GResourceFindColor("GMatrixEdit.TitleFG",gmatrixedit_title_fg);
gmatrixedit_title_divider = GResourceFindColor("GMatrixEdit.TitleDivider",gmatrixedit_title_divider);
diff -urN fontforge-20170731.old/gdraw/gmenu.c fontforge-20170731/gdraw/gmenu.c
--- fontforge-20170731.old/gdraw/gmenu.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gmenu.c 2018-09-23 14:50:31.596567096 +0530
@@ -145,6 +145,7 @@
menu_3d_look = GResourceFindBool("GMenu.3DLook", menu_3d_look);
gmenubar_inited = true;
_GGroup_Init();
+ free(keystr);
}
typedef struct gmenu {
@@ -388,8 +389,12 @@
strcat(buffer,".");
if( stack[i]->ti.text_untranslated )
{
-// TRACE("adding %s\n", HKTextInfoToUntranslatedTextFromTextInfo( &stack[i]->ti ));
- strcat( buffer, HKTextInfoToUntranslatedTextFromTextInfo( &stack[i]->ti ));
+ char *res;
+ res = calloc(PATH_MAX, sizeof(char));
+ res = HKTextInfoToUntranslatedTextFromTextInfo( &stack[i]->ti );
+// TRACE("adding %s\n", res);
+ strcat( buffer, res);
+ free(res);
}
else if( stack[i]->ti.text )
{
diff -urN fontforge-20170731.old/gdraw/gpstxtinit.c fontforge-20170731/gdraw/gpstxtinit.c
--- fontforge-20170731.old/gdraw/gpstxtinit.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gpstxtinit.c 2018-09-23 14:50:31.596567096 +0530
@@ -503,6 +503,7 @@
}
}
fonts->names_loaded = true;
+ free(path);
return( fonts->names_loaded );
}
diff -urN fontforge-20170731.old/gdraw/gtextinfo.c fontforge-20170731/gdraw/gtextinfo.c
--- fontforge-20170731.old/gdraw/gtextinfo.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gtextinfo.c 2018-09-23 14:50:31.597567080 +0530
@@ -582,6 +582,7 @@
free(fname);
ri->filename = fname = absname;
}
+ free(absname);
}
if ( ret==NULL ) {
ri->filename = NULL;
diff -urN fontforge-20170731.old/gdraw/gxdraw.c fontforge-20170731/gdraw/gxdraw.c
--- fontforge-20170731.old/gdraw/gxdraw.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gdraw/gxdraw.c 2018-09-23 14:50:31.597567080 +0530
@@ -910,7 +910,6 @@
}
if ( (wattrs->mask&wam_ititle) && wattrs->icon_title!=NULL ) {
XmbSetWMProperties(display,nw->w,NULL,(pt = u2def_copy(wattrs->icon_title)),NULL,0,NULL,NULL,NULL);
- free(pt);
}
if ( (wattrs->mask&wam_utf8_wtitle) && wattrs->utf8_window_title!=NULL ) {
#ifdef X_HAVE_UTF8_STRING
@@ -918,7 +917,7 @@
#else
unichar_t *tit = utf82u_copy(wattrs->utf8_window_title);
XmbSetWMProperties(display,nw->w,(pt = u2def_copy(tit)),NULL,NULL,0,NULL,NULL,NULL);
- free(pt); free(tit);
+ free(tit);
#endif
}
if ( (wattrs->mask&wam_utf8_ititle) && wattrs->utf8_icon_title!=NULL ) {
@@ -927,7 +926,7 @@
#else
unichar_t *tit = utf82u_copy(wattrs->utf8_icon_title);
XmbSetWMProperties(display,nw->w,NULL,(pt = u2def_copy(tit)),NULL,0,NULL,NULL,NULL);
- free(pt); free(tit);
+ free(tit);
#endif
}
s_h.x = pos->x; s_h.y = pos->y;
diff -urN fontforge-20170731.old/gutils/gimagereadrgb.c fontforge-20170731/gutils/gimagereadrgb.c
--- fontforge-20170731.old/gutils/gimagereadrgb.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gutils/gimagereadrgb.c 2018-09-23 14:50:31.597567080 +0530
@@ -313,6 +313,7 @@
free(r); free(g); free(b); free(a);
}
}
+ free(fp);
return( ret );
errorGImageReadRgbFile:
diff -urN fontforge-20170731.old/gutils/gioftp.c fontforge-20170731/gutils/gioftp.c
--- fontforge-20170731.old/gutils/gioftp.c 2017-07-31 03:19:01.000000000 +0530
+++ fontforge-20170731/gutils/gioftp.c 2018-09-23 14:50:31.598567065 +0530
@@ -697,6 +697,7 @@
if ( ctl!=-1 ) close(ctl);
free(path);
free(host); free(username); free(password);
+ free(had);
return( NULL );
}
diff -urN fontforge-20170731.old/pycontrib/FontCompare/fc/GlyphConsistency.py fontforge-20170731/pycontrib/FontCompare/fc/GlyphConsistency.py
--- fontforge-20170731.old/pycontrib/FontCompare/fc/GlyphConsistency.py 2018-09-21 13:53:18.533769952 +0530
+++ fontforge-20170731/pycontrib/FontCompare/fc/GlyphConsistency.py 2018-09-23 14:50:31.598567065 +0530
@@ -83,7 +83,7 @@
if not font[i].boundingBox()[3] in ymax_cords:
ymax_cords.append(font[i].boundingBox()[3])
if not font[i].left_side_bearing in lbearing:
- rbearing.append(font[i].left_side_bearing)
+ lbearing.append(font[i].left_side_bearing)
if not font[i].right_side_bearing in rbearing:
rbearing.append(font[i].right_side_bearing)
if not font[i].layer_cnt in layer_cnts: