zyedidia
Joined 11 years ago
Karma
150
Submissions
45
Member since
Sep 5
https://github.com/zyedidia
View on Hacker NewsJoined 11 years ago
[1]: https://youtu.be/dKHopzDtElY?si=jc3ho2NT4vPTbXBz&t=14
[2]: See FAQ here https://awesomekling.github.io/Ladybird-a-new-cross-platform...
void* p1 = malloc(...);
if (!p1) goto err1;
void* p2 = malloc(...);
if (!p2) goto err2;
void* p3 = malloc(...);
if (!p3) goto err3;
return {p1, p2, p3};
err3: free(p2);
err2: free(p1);
err1: return NULL;
With defer I think I would have to use a "success" boolean like this: bool success = false;
void* p1 = malloc(...);
if (!p1) return NULL;
defer { if (!success) free(p1) }
void* p2 = malloc(...);
if (!p2) return NULL;
defer { if (!success) free(p2) }
void* p3 = malloc(...);
if (!p3) return NULL;
defer { if (!success) free(p3) }
success = true;
return {p1, p2, p3};
I'm not sure if this has really improved things. I do see the use-case for locks and functions that allocate/free together though.[1]: https://www.usenix.org/system/files/sec21summer_wickman.pdf
These bugs are not really a problem in practice though as long as the developer is not malicious. However, they are a problem for supply chain security or any case where the Rust source is fully untrusted.
[1]: https://github.com/rust-lang/rust/issues/25860
Is it really the case that browsers have default-enabled all sorts of extensions that are not yet widely supported by the rest of the ecosystem?