On Thu Dec 18 22:41 , 'James Hawkins' truiken@gmail.com sent:
I didn't write jscript, so I'm not the expert, but create_string is internal, so we should probably crash if str is NULL instead of hiding the error. What is this patch for?
-- James Hawkins
Hi James,
create_string() is called on line 1323 of this file, with str == NULL and len = 0. This function always allocates memory for at least one one WCHAR, so I zero-terminated it.
Andrew Talbot wrote:
On Thu Dec 18 22:41 , 'James Hawkins' truiken@gmail.com sent:
I didn't write jscript, so I'm not the expert, but create_string is internal, so we should probably crash if str is NULL instead of hiding the error. What is this patch for?
-- James Hawkins
Hi James,
create_string() is called on line 1323 of this file, with str == NULL and len = 0. This function always allocates memory for at least one one WCHAR, so I zero-terminated it.
The string was always zero-terminated without your patch. It's fine to call create_string with NULL str argument as long as len is 0 and current implementation works fine in this case.
Jacek
Jacek Caban wrote:
The string was always zero-terminated without your patch. It's fine to call create_string with NULL str argument as long as len is 0 and current implementation works fine in this case.
Jacek
Hi Jacek,
Technically, behavior is undefined if the pointers do not each point to an object, even if the size parameter has a value of zero (see http://tinyurl.com/6eqo3n, third post). Though I concede that it would be a rare implementation that touched its pointers (or copies of them) in that case.
Hi Andrew,
Andrew Talbot wrote:
Jacek Caban wrote:
The string was always zero-terminated without your patch. It's fine to call create_string with NULL str argument as long as len is 0 and current implementation works fine in this case.
Jacek
Hi Jacek,
Technically, behavior is undefined if the pointers do not each point to an object, even if the size parameter has a value of zero (see http://tinyurl.com/6eqo3n, third post). Though I concede that it would be a rare implementation that touched its pointers (or copies of them) in that case.
I'm not fan of such fixes, but if you want to fix it, you should check len, not str, in your patch and you may move zero-terminating outside if..else statement.
Jacek
Jacek Caban wrote:
I'm not fan of such fixes, but if you want to fix it, you should check len, not str, in your patch and you may move zero-terminating outside if..else statement.
Jacek
Thank you, I shall fix it in the better way that you describe here.