Skip to content

Conversation

Flimm
Copy link
Contributor

@Flimm Flimm commented Jan 7, 2015

This eliminates some of the warnings from the compiler.

https://rt.cpan.org/Public/Bug/Display.html?id=91967

This eliminates some of the warnings from the compiler.

https://rt.cpan.org/Public/Bug/Display.html?id=91967
fread(&(RETVAL->state), sizeof(uuid_state_t), 1, fd);
if (! fread(&(RETVAL->state), sizeof(uuid_state_t), 1, fd)) {
croak("fread failed");
}
fclose(fd);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling croak(...) here leaves the fd open and leaks the file handle.

To see this in action on linux:

mkdir /tmp/.UUID_STATE
perl -Iblib/lib -Iblib/arch -MData::UUID -e 'eval { Data::UUID->new } for 1..100; <>;'

And in another terminal:

lsof | grep .UUID_STATE

We should fclose(fd) before calling croak every time that fd is already open.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants