Skip to content
Browse files

Don't do a 64bit read access from a string, since it may not be 64bit…

… aligned.

Fixes crash with CPUs that require aligned access.
  • Loading branch information...
1 parent 249dfb5 commit 2d583700f44c5e88d5f0f795dc99975c0cc2c9df Timo Sirainen committed Apr 30, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/network/transportfragment.cc
View
5 src/network/transportfragment.cc
@@ -64,9 +64,10 @@ Fragment::Fragment( string &x )
{
assert( x.size() >= frag_header_len );
- uint64_t *data64 = (uint64_t *)x.data();
+ uint64_t data64;
uint16_t *data16 = (uint16_t *)x.data();
- id = be64toh( data64[ 0 ] );
+ memcpy( &data64, x.data(), sizeof( data64 ) );
+ id = be64toh( data64 );
fragment_num = be16toh( data16[ 4 ] );
final = ( fragment_num & 0x8000 ) >> 15;
fragment_num &= 0x7FFF;

0 comments on commit 2d58370

Please sign in to comment.
Something went wrong with that request. Please try again.