ecarter / node-pdfinfo

A simple api for reading PDF meta info via xpdf's pdfinfo(1)
4 stars 8 forks source link

Fixed crashes when using node-pdfinfo #2

Closed pbellon closed 10 years ago

pbellon commented 11 years ago

If for a strange reason the results variable is undefined or null in the map function the code will break because of the for loop used as bellow:

// will break because of calling 'length' property on undefined
for(var i = 0; i < results.length ; i++){ 
   var result = results[i];
   // stuff
}

A good way to avoid these issues is to use the other for syntax:

// will not break if results is undefined
for(var i in results){ 
  var result = results[i]; 
  // stuff 
}
ecarter commented 10 years ago

Good catch! Your changes have been merged into master and npm has been updated to version 0.0.3

It's been a while since I've touched this project but just wanted to say thanks for your pull request and contribution :wink: