silgraphite-2.3.1-aligned_access.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Fix unaligned reads.
  2. https://bugs.gentoo.org/show_bug.cgi?id=304921
  3. Upstream:
  4. https://sourceforge.net/tracker/?func=detail&aid=2995413&group_id=66144&atid=513479
  5. Index: silgraphite-2.3.1/engine/src/segment/FileInput.cpp
  6. ===================================================================
  7. --- silgraphite-2.3.1.orig/engine/src/segment/FileInput.cpp
  8. +++ silgraphite-2.3.1/engine/src/segment/FileInput.cpp
  9. @@ -41,6 +41,10 @@ DEFINE_THIS_FILE
  10. //:End Ignore
  11. +#define RAW_READ(var,size,buf) \
  12. + for(int i = 0; i < isizeof(size);i++){\
  13. + var |= buf[i]<<8*(isizeof(size)-i-1);\
  14. + }
  15. //:>********************************************************************************************
  16. //:> Forward declarations
  17. //:>********************************************************************************************
  18. @@ -133,11 +137,11 @@ byte GrBufferIStream::ReadByteFromFont()
  19. ----------------------------------------------------------------------------------------------*/
  20. short GrBufferIStream::ReadShortFromFont()
  21. {
  22. - short snInput = *(short *)m_pbNext;
  23. + short snInput = 0;
  24. + RAW_READ(snInput,short,m_pbNext);
  25. m_pbNext += isizeof(short);
  26. if (m_pbLim && m_pbNext > m_pbLim)
  27. THROW(kresReadFault);
  28. - snInput = lsbf(snInput);
  29. return snInput;
  30. }
  31. @@ -147,11 +151,11 @@ short GrBufferIStream::ReadShortFromFont
  32. ----------------------------------------------------------------------------------------------*/
  33. utf16 GrBufferIStream::ReadUShortFromFont()
  34. {
  35. - utf16 chwInput = *(utf16 *)m_pbNext;
  36. + utf16 chwInput = 0;
  37. + RAW_READ(chwInput,utf16,m_pbNext);
  38. m_pbNext += isizeof(utf16);
  39. if (m_pbLim && m_pbNext > m_pbLim)
  40. THROW(kresReadFault);
  41. - chwInput = lsbf(chwInput);
  42. return chwInput;
  43. }
  44. @@ -161,11 +165,11 @@ utf16 GrBufferIStream::ReadUShortFromFon
  45. ----------------------------------------------------------------------------------------------*/
  46. int GrBufferIStream::ReadIntFromFont()
  47. {
  48. - int nInput = *(int *)m_pbNext;
  49. + int nInput = 0;
  50. + RAW_READ(nInput,int,m_pbNext);
  51. m_pbNext += isizeof(int);
  52. if (m_pbLim && m_pbNext > m_pbLim)
  53. THROW(kresReadFault);
  54. - nInput = lsbf(nInput);
  55. return nInput;
  56. }