-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fix: used allocation without checking #9015
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
base: PHP-8.0
Are you sure you want to change the base?
Conversation
18a4241
to
3d23209
Compare
Thanks for the PR! This is okay, but why not use |
3d23209
to
e9a604f
Compare
I changed to pemalloc, I would be happy if you change it to PHP-8.0 ... who knows what will happen if I try ... |
btw. if I look at the define of
the persistent half doesn't look safe to me. |
I can do, but usually its easy to do:
Ugh! |
e9a604f
to
d3f332a
Compare
@@ -3333,12 +3333,12 @@ static zend_ffi *zend_ffi_load(const char *filename, zend_bool preload) /* {{{ * | |||
} | |||
|
|||
if (!scope) { | |||
scope = malloc(sizeof(zend_ffi_scope)); | |||
scope = pemalloc(sizeof(zend_ffi_scope), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might need to mirror it in their freeing counterparts.
scope->symbols = FFI_G(symbols); | ||
scope->tags = FFI_G(tags); | ||
|
||
if (!FFI_G(scopes)) { | ||
FFI_G(scopes) = malloc(sizeof(HashTable)); | ||
FFI_G(scopes) = pemalloc(sizeof(HashTable), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
I've filed #9128. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should target master
. If we want it in PHP-8.0 we also need to back-port 98bdb7f.
@@ -1306,7 +1306,7 @@ static const maker_note_type maker_note_array[] = { | |||
|
|||
static HashTable *exif_make_tag_ht(tag_info_type *tag_table) | |||
{ | |||
HashTable *ht = malloc(sizeof(HashTable)); | |||
HashTable *ht = pemalloc(sizeof(HashTable), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be persistent. ht
is later stored in EXIF_G(tag_table_cache)
which lives beyond requests, as far as I can see.
{ | ||
char *cur, *end; | ||
int n; | ||
|
||
if (ip) { | ||
ip = strdup(ip); | ||
cur = ip; | ||
char *dup_ip = estrdup(ip); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see this functions is called from fpm_php_init_child
which is called indirectly from main outside of request context. I guess this should work fine if the allocator is started, I'm not sure which one is preferable.
@@ -758,12 +758,12 @@ static void sapi_cgi_log_message(const char *message, int syslog_type_int) | |||
request = (fcgi_request*) SG(server_context); | |||
if (request) { | |||
int ret, len = (int)strlen(message); | |||
char *buf = malloc(len+2); | |||
|
|||
char *buf = pemalloc(len+2, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this can be called outside of request context.
@hwde Could you please rebase this on top of PHP-8.1 and address review comments? |
No description provided.