Skip to content
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

Fix allocating and releasing memory #94

Merged
merged 2 commits into from
Oct 2, 2018
Merged

Fix allocating and releasing memory #94

merged 2 commits into from
Oct 2, 2018

Conversation

pali
Copy link
Member

@pali pali commented Oct 1, 2018

Use only Perl's alloc/free functions. Perl redefines C library alloc
functions (malloc, realloc, free) to its own memory allocation and
therefore it is not safe to use C library functions which allocate memory.

Perl doesn't redefine calloc() so its usage is not safe as far as it
allocates using C library memory management but frees with Perl's.

See also: #91

Macro Newz() takes as third argument number of items in target array, not
size of whole structure.
Use only Perl's alloc/free functions. Perl redefines C library alloc
functions (malloc, realloc, free) to its own memory allocation and
therefore it is not safe to use C library functions which allocate memory.

Perl doesn't redefine calloc() so its usage is not safe as far as it
allocates using C library memory management but frees with Perl's.

See also: perl5-dbi#91
"Initialize embedded server. Out of memory \n");
return NULL;
}
Newz(908, options_list, cnt, char *);

Choose a reason for hiding this comment

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

one concern, so now it's just croak when OOM and not output anything to stream :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, when there is no free memory, other memory allocations (in perl interpreter too; in DBI.xs too) would fail too.

@pali pali merged commit d57397e into perl5-dbi:master Oct 2, 2018
pali added a commit that referenced this pull request Oct 2, 2018
Fix allocating and releasing memory
@pali pali mentioned this pull request Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants