mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-08 11:28:42 +00:00
v8js_commonjs_split_terms: use pointer comparison instead of strlen
The strlen usage on term obviously was wrong here, since the term string is not null-terminated at that place.
This commit is contained in:
parent
cedcac1318
commit
441f7b7fab
@ -8,6 +8,7 @@ Test V8Js::setModuleLoader : Path normalisation #003
|
||||
$JS = <<< EOT
|
||||
var foo = require("foo/test");
|
||||
var foo = require("foo/bar/baz/test");
|
||||
var foo = require("foo//bar//baz//blub");
|
||||
EOT;
|
||||
|
||||
$v8 = new V8Js();
|
||||
@ -22,4 +23,5 @@ $v8->executeString($JS, 'module.js');
|
||||
--EXPECT--
|
||||
setModuleLoader called for foo/test
|
||||
setModuleLoader called for foo/bar/baz/test
|
||||
setModuleLoader called for foo/bar/baz/blub
|
||||
===EOF===
|
||||
|
@ -31,7 +31,7 @@ static void v8js_commonjs_split_terms(const char *identifier, std::vector<char *
|
||||
|
||||
while (*identifier > 0) {
|
||||
if (*identifier == '/') {
|
||||
if (strlen(term) > 0) {
|
||||
if (ptr > term) {
|
||||
// Terminate term string and add to terms vector
|
||||
*ptr++ = 0;
|
||||
terms.push_back(estrdup(term));
|
||||
@ -47,7 +47,7 @@ static void v8js_commonjs_split_terms(const char *identifier, std::vector<char *
|
||||
identifier++;
|
||||
}
|
||||
|
||||
if (strlen(term) > 0) {
|
||||
if (ptr > term) {
|
||||
// Terminate term string and add to terms vector
|
||||
*ptr++ = 0;
|
||||
terms.push_back(estrdup(term));
|
||||
|
Loading…
Reference in New Issue
Block a user