Re: more bug fixes

Martin Hosken <[email protected]>
Newsgroups gmane.comp.fonts.fontforge.devel
Message-ID <20131015084011.143ca7e0@sil-mh6>
Dear Joe,

> > Fix a bug when loading Layer names. Half undo a previous commit which I
> > am unsure as to why it was done.
> > 
> > diff --git a/fontforge/sfd.c b/fontforge/sfd.c
> > index 220d937..aaafbe7 100644
> > --- a/fontforge/sfd.c
> > +++ b/fontforge/sfd.c
> > @@ -441,11 +441,11 @@ return( NULL );
> >                 done = true;
> >             }
> >         }
> > -       if ( pt && pt+10>=end ) {
> > +       if ( pt+10>=end ) {
> >             if ( buffer==NULL ) {
> >                 pt = buffer = galloc(400);
> >                 end = buffer+400;
> > -           } else {
> > +           } else if (pt) {
> >                 char *temp = grealloc(buffer,end-buffer+400);
> >                 pt = temp+(pt-buffer);
> >                 end = temp+(end-buffer+400);
> 
> The previous utf8_idpb() function had the possibility of failing silently 
> if it encountered a bad code, which to me I think could have been improved 
> a bit further. The patches for utf8_ispb allows for the possibility of 
> returning failure to convert the last value by returning 0.
> There are many routines within FontForge which could be treated similarly 
> in making them return fail/pass instead of assuming everything works 100%.

OK. But the code that is currently in there for UTF7 doesn't work. It always returns an empty string. This is because you never create a buffer. Since in the first pass through, pt is NULL, the pt && pt+10>=end doesn't pass and so buffer isn't created and pt remains 0. If no pt, then no call to utf8_idpb and a quick exit. I think my patch does what you want in this respect in that the first time through it will create a buffer, then if pt is set to 0 by utf8_ipdb then it will pass through the inside ifs with no changes.

> This routine 'above' really needs to be checked from top to bottom to 
> verify all if-then-else do what's expected.
> The (pt && pt+10>=end) was just a 'quick' check for the possibility of if 
> pt becomes zero if utf8_idpb returns zero on error.

Agreed. If I were to do it, I would probably rewrite. It looks ugly as sin, but that may just be the nature of the problem. Anyway, I suggest that my patch fixes both of our problems.

BTW, the first patch in my first message on this thread is the key patch that needs to be applied (and I don't see it in the repo yet) which fixes the segfault that can occur if you try to draw a curve that doesn't start with an on curve point.

Yours,
Martin

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.