cherry-pick.v2.9.4-9-g4f15b7d.fix-sizeof-http-parser-assert.patch 1.0 KB

1234567891011121314151617181920212223242526272829
  1. Subject: Fix sizeof(http_parser) assert
  2. Origin: v2.9.4-9-g4f15b7d <https://github.com/joyent/http-parser/commit/v2.9.4-9-g4f15b7d>
  3. Upstream-Author: Ben Noordhuis <info@bnoordhuis.nl>
  4. Date: Fri Jul 10 11:55:11 2020 +0200
  5. The result should be 32 on both 32 bits and 64 bits x86 because of
  6. struct padding.
  7. Fixes: https://github.com/nodejs/http-parser/issues/507
  8. PR-URL: https://github.com/nodejs/http-parser/pull/510
  9. Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  10. --- a/test.c
  11. +++ b/test.c
  12. @@ -4221,7 +4221,13 @@
  13. printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version);
  14. printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser));
  15. - assert(sizeof(http_parser) == 4 + 4 + 8 + 2 + 2 + 4 + sizeof(void *));
  16. +
  17. +#if defined(__i386__) || defined(__x86_64__)
  18. + /* Should be 32 on both 32 bits and 64 bits x86 because of struct padding,
  19. + * see https://github.com/nodejs/http-parser/issues/507.
  20. + */
  21. + assert(sizeof(http_parser) == 32);
  22. +#endif
  23. //// API
  24. test_preserve_data();