[Webkit-unassigned] [Bug 28131] [Haiku] Adding font-specific files to WebCore.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Aug 21 01:42:38 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=28131





--- Comment #21 from Oliver Hunt <oliver at apple.com>  2009-08-21 01:42:38 PDT ---
> If I wrote "return &family" then the compiler warned me. But if I made it like
> this, it didn't complain (maybe an issue in our gcc version). Anyway, I made
> some tests and it works as it. It may be a stroke of luck and it will not work
> another time.

GCC was warning you precisely because return the address of a local is unsafe
-- it may "work" but it is fundamentally unsound.  What your patch does is
deliberately circumvent gcc attempting to tell you that your code is broken.

take (for example):

int* foo() {
    int bar = 3;
    return &bar;
}

int main() {
   int* f = foo();
   printf("%d\n", *f);
   printf("%d\n", *f);
   return 0;
}

You will (probably) get two different numbers output, because you have returned
the address of a local, eg. a pointer to some arbitrary location on the stack. 
The next function you call uses the same section of the stack for whatever it
needs to do and the value you thought you were pointing to is now gone.

In general when gcc warns you against do something it's better to not do it
than to just try and make the warning go away :D

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list