New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Croak when fread,flock,lockf fail #14

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@Flimm
Contributor

Flimm commented Jan 7, 2015

This eliminates some of the warnings from the compiler.

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

Croak when fread,flock,lockf fail
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);

This comment has been minimized.

@wolfsage

wolfsage Jan 17, 2015

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.

@wolfsage

wolfsage Jan 17, 2015

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.

@rjbs rjbs added the Needs Rework label Aug 1, 2015

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