[poppler] Clipping text in Splash before rendering it
jeff at infidigm.net
Sun Oct 14 13:16:19 PDT 2007
On Sun, Oct 14, 2007 at 12:09:59PM +0200, Albert Astals Cid wrote:
> A Diumenge 14 Octubre 2007, Jeff Muizelaar va escriure:
> > On Sun, Oct 14, 2007 at 01:17:05AM +0200, Albert Astals Cid wrote:
> > > Hi, this patch has two parts.
> > >
> > > First, it removes all exit(1) calls in favor or the best i could find,
> > > that is, return NULL (and hope the caller can understand NULL as error)
> > > in the gmem routines and the correct ignore in DCTStream.
> > What's the motivation for this? Won't the callers just segfault
> > afterwards anyways? It looks like most callers assume that gammloc
> > succeeds. If we wanted to deal with the out of memory situation it would
> > require quite a bit of work to add all of the proper error handling
> > code. At least with exisiting implementation the application dies
> > cleanly instead of segfaulting. It would be nice to deal with
> > out-of-memory properly, but I think it would be quite a bit of work...
> The motivation is that without it my splash patch is worthless because the
> huge font tries to create a huge cache (before i can discard it because it's
> out of the clip area) that integer wraps a gmallocn call and i got an app
> exit(), making it return NULL gets it to work without any problem.
Well that explains why you had them together :)
> I agree in most other situations will probably segfault, but as i said exit()
> in library code is a bad idea, so when we hit those segfaults because of the
> return NULL we try to fix them instead of the exit(1).
> Of course i can catch the integer wrapping in the code that calls gmallocn but
> why duplicating checks everywhere if you can have them at one place only?
I agree with you here. It makes sense to have this code common. However,
that only applies to gmallocn. If we change only gmallocn, instead of
all of the varients then there are fewer places that would need to check
for NULL and do something appropriate if they got NULL. Alternatively,
we could have a gmallocn_checkoverflow() that returns NULL and gradually
adjust move callers to it and then possibly rename it to gmallocn once
all the callers check for NULL.
More information about the poppler