Close file handle too in case we fail in nbio_open

This commit is contained in:
twinaphex 2015-02-15 23:30:28 +01:00
parent b1558d651e
commit cfa388ed77

View File

@ -29,7 +29,10 @@ struct nbio_t* nbio_open(const char * filename, enum nbio_mode_t mode)
handle=(struct nbio_t*)malloc(sizeof(struct nbio_t));
if (!handle)
{
fclose(f);
return NULL;
}
handle->f = f;
handle->len = 0;
@ -45,6 +48,7 @@ struct nbio_t* nbio_open(const char * filename, enum nbio_mode_t mode)
if (!handle->data)
{
free(handle);
fclose(f);
return NULL;
}