Permalink
Browse files

additional bug fix for TypeError

  • Loading branch information...
bjyoungblood committed Mar 9, 2013
1 parent 176159d commit fb31211a4f05ee6096b39338bc47b9b61a6cf612
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/pdu-writer.js
View
@@ -52,7 +52,7 @@ exports.write = function(pdu) {
} else if (field.type === "c-string") {
// get the actual byte length of the string, then add 1 for the
// null terminator
-
+
// Don't try to do anything to a buffer
if (!Buffer.isBuffer(field.value)) {
if (typeof field.value === 'string') {
@@ -155,7 +155,7 @@ exports.write = function(pdu) {
}
} else if (field.type === "c-string") {
// TODO still need to do error checking for out-of-bounds lengths
-
+
/**
* Unlike with reading, this method can actually be the same for
* fixed- and variable-length strings
@@ -187,12 +187,12 @@ exports.write = function(pdu) {
if (definition.octets !== undefined) {
length += definition.octets;
} else {
- if (Buffer.isBuffer(pdu.optional_params[param])) {
- length += pdu.optional_params[param].length;
+ if (Buffer.isBuffer(param)) {
+ length += param.length;
} else {
length += Buffer.byteLength(param);
}
- }
+ }
// Write the tag and length -- 2 bytes each
buffer.writeUInt16BE(definition.tag, offset);

0 comments on commit fb31211

Please sign in to comment.