Skip to content

Commit

Permalink
Ensured parser#decodePayload doesn't choke.
Browse files Browse the repository at this point in the history
This addresses the situation where malformed data is supplied to the parser.
Fixes #510
  • Loading branch information
rauchg committed Sep 7, 2011
1 parent 9e6f58f commit cb73048
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ exports.decodePacket = function (data) {
*/

exports.decodePayload = function (data) {
if (undefined == data || null == data) {

This comment has been minimized.

Copy link
@tbranyen

tbranyen Sep 7, 2011

Hey @guille wouldn't if (data == null) be sufficient here? I'm nitpicking, but it seems like a Yoda conditional :-p

This comment has been minimized.

Copy link
@rauchg

rauchg Sep 7, 2011

Author Contributor

oops true that sorry

return [];
}

if (data[0] == '\ufffd') {
var ret = [];

Expand Down

0 comments on commit cb73048

Please sign in to comment.