Comment by cyberax

4 days ago

Uhh... This is an example why C is so bad for network-facing stuff:

https://github.com/ashtonjamesd/lavandula/blob/2dbefe6da16bf... - is it intended?

https://github.com/ashtonjamesd/lavandula/blob/2dbefe6da16bf... - pain....

I get the first one but what is the issue with the second one? It looks like a fairly standard dynamic array with separate size and capacity.

  • Missing null pointer check on return, leaks memory because it overwrites the original pointer.

    • I didn't notice that, but TBH is this a realistic concern? Is there an actual platform nowadays where realloc (and malloc, for that matter) ever fails, at least outside (small) embedded environments? I've being using realloc for decades and the only time i had to worry about it failing was in DOS.

      Nowadays it feels like worrying about realloc failing is similar to worrying about fclose failing.

      2 replies →

  • No null pointer check, and the fact that you have to manually rewrite it every time.