0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 04:01:51 +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:
Stefan Siegl 2015-08-01 19:54:23 +02:00
parent cedcac1318
commit 441f7b7fab
2 changed files with 4 additions and 2 deletions

View File

@ -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===

View File

@ -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));