Problem: string buffers aren't NULL checked

Have found some places where memory is allocated and not NULL checked.
I have not touched the auto generated engine for zgossip which is also not checking for NULL pointers from strdup.

Tests pass locally.
Poor error handling makes unsafe code worse. There are two styles that work
well, which we use in CZMQ:

    do something speculative
    if (that worked)
        do next speculative
    if (that also worked)
        do last thing
    else
        abandon/return

which works well with a zerofied structure. Then,

    do something speculative
    assert (that worked)
    do next speculative
    assert (that also worked)
    do last thing

which works when we want to catch the problem and don't have a clean way to
handle it.

On Tue, Nov 25, 2014 at 6:38 AM, Asmod4n <notifications@github.com> wrote:

> In src/zhash.c:
>
> > @@ -583,6 +586,9 @@ zhash_load (zhash_t *self, const char *filename)
> >          return -1;              //  Failed to open file for reading
> >
> >      char *buffer = (char *) zmalloc (1024);
> > +    if (!buffer)
> > +        return -1;
>
> @xaqq <https://github.com/xaqq> this looks better?
> https://gist.github.com/Asmod4n/8efe91b3ba5454cbe796
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/zeromq/czmq/pull/824/files#r20844232>.
>