@@ -1320,7 +1320,7 @@ Handle<Value> Connection::EncIn(const Arguments& args) {
13201320
13211321 size_t off = args[1 ]->Int32Value ();
13221322 size_t len = args[2 ]->Int32Value ();
1323- if (off + len > buffer_length) {
1323+ if (! Buffer::IsWithinBounds ( off, len, buffer_length) ) {
13241324 return ThrowException (Exception::Error (
13251325 String::New (" off + len > buffer.length" )));
13261326 }
@@ -1361,7 +1361,7 @@ Handle<Value> Connection::ClearOut(const Arguments& args) {
13611361
13621362 size_t off = args[1 ]->Int32Value ();
13631363 size_t len = args[2 ]->Int32Value ();
1364- if (off + len > buffer_length) {
1364+ if (! Buffer::IsWithinBounds ( off, len, buffer_length) ) {
13651365 return ThrowException (Exception::Error (
13661366 String::New (" off + len > buffer.length" )));
13671367 }
@@ -1437,7 +1437,7 @@ Handle<Value> Connection::EncOut(const Arguments& args) {
14371437
14381438 size_t off = args[1 ]->Int32Value ();
14391439 size_t len = args[2 ]->Int32Value ();
1440- if (off + len > buffer_length) {
1440+ if (! Buffer::IsWithinBounds ( off, len, buffer_length) ) {
14411441 return ThrowException (Exception::Error (
14421442 String::New (" off + len > buffer.length" )));
14431443 }
@@ -1471,7 +1471,7 @@ Handle<Value> Connection::ClearIn(const Arguments& args) {
14711471
14721472 size_t off = args[1 ]->Int32Value ();
14731473 size_t len = args[2 ]->Int32Value ();
1474- if (off + len > buffer_length) {
1474+ if (! Buffer::IsWithinBounds ( off, len, buffer_length) ) {
14751475 return ThrowException (Exception::Error (
14761476 String::New (" off + len > buffer.length" )));
14771477 }
0 commit comments