On Wednesday, 10 May 2017 at 00:30:42 UTC, H. S. Teoh wrote:
                strncpy(tmp, desc->data1, bufsz);
                if (fwrite(tmp, strlen(tmp), 1, fp) != 1)
                {
                        fclose(fp);
                        unlink("blah");
                        return IO_ERROR;
                }

                strncpy(tmp, desc->data2, bufsz);
                if (fwrite(tmp, strlen(tmp), 1, fp) != 1)
                {
                        fclose(fp);
                        unlink("blah");
                        return IO_ERROR;
                }

I think you cause a memory leak in these branches because you forget to free tmp before returning.

Side note: scope(exit) is one of the best inventions in PLs ever.

Reply via email to