patch-src_lexer_c 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. $OpenBSD: patch-src_lexer_c,v 1.1 2015/06/25 08:28:58 sthen Exp $
  2. From htacg/tidy-html5; problem also applies to tidyp
  3. From c18f27a58792f7fbd0b30a0ff50d6b40a82f940d Mon Sep 17 00:00:00 2001
  4. From: Geoff McLane <ubuntu@geoffair.info>
  5. Date: Wed, 3 Jun 2015 20:26:03 +0200
  6. Subject: [PATCH] Issue #217 - avoid len going negative, ever...
  7. --- src/lexer.c.orig Thu Jun 25 09:25:06 2015
  8. +++ src/lexer.c Thu Jun 25 09:25:52 2015
  9. @@ -3419,16 +3419,16 @@ static tmbstr ParseValue( TidyDocImpl* doc, ctmbstr na
  10. /* and prompts attributes unless --literal-attributes is set to yes */
  11. /* #994841 - Whitespace is removed from value attributes */
  12. - if (munge &&
  13. + if ((len > 0) && munge &&
  14. TY_(tmbstrcasecmp)(name, "alt") &&
  15. TY_(tmbstrcasecmp)(name, "title") &&
  16. TY_(tmbstrcasecmp)(name, "value") &&
  17. TY_(tmbstrcasecmp)(name, "prompt"))
  18. {
  19. - while (TY_(IsWhite)(lexer->lexbuf[start+len-1]))
  20. + while (TY_(IsWhite)(lexer->lexbuf[start+len-1]) && (len > 0))
  21. --len;
  22. - while (TY_(IsWhite)(lexer->lexbuf[start]) && start < len)
  23. + while (TY_(IsWhite)(lexer->lexbuf[start]) && (start < len) && (len > 0 ))
  24. {
  25. ++start;
  26. --len;