Skip to content

Commit 6a3bd6a

Browse files
authored
core: fix crash when payload pack_id is not numeric (#440)
1 parent da77914 commit 6a3bd6a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/internal/sio_packet.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,14 @@ namespace sio
321321

322322
if(pos<json_pos)//we've got pack id.
323323
{
324-
_pack_id = std::stoi(payload_ptr.substr(pos,json_pos - pos));
324+
std::string pack_id_str = payload_ptr.substr(pos, json_pos - pos);
325+
326+
if (std::all_of(pack_id_str.begin(), pack_id_str.end(), ::isdigit)) {
327+
_pack_id = std::stoi(pack_id_str);
328+
}
329+
else {
330+
_pack_id = -1;
331+
}
325332
}
326333
if (_frame == frame_message && (_type == type_binary_event || _type == type_binary_ack)) {
327334
//parse later when all buffers are arrived.

0 commit comments

Comments
 (0)