You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
797 B

  1. From 3bdeed02505c9bbacb3b64a97ddcb1de967153b7 Mon Sep 17 00:00:00 2001
  2. From: Willem Toorop <willem@nlnetlabs.nl>
  3. Date: Thu, 27 Apr 2017 00:25:20 +0200
  4. Subject: [PATCH] bugfix #1257: Free after reallocing to 0 size
  5. Thanks Stephan Zeisberg
  6. ---
  7. str2host.c | 6 ++++--
  8. 1 file changed, 4 insertions(+), 2 deletions(-)
  9. diff --git a/str2host.c b/str2host.c
  10. index b274b17..f2a317b 100644
  11. --- a/str2host.c
  12. +++ b/str2host.c
  13. @@ -1525,8 +1525,10 @@ ldns_str2rdf_long_str(ldns_rdf **rd, const char *str)
  14. if (! str) {
  15. return LDNS_STATUS_SYNTAX_BAD_ESCAPE;
  16. }
  17. - length = (size_t)(dp - data);
  18. -
  19. + if (!(length = (size_t)(dp - data))) {
  20. + LDNS_FREE(data);
  21. + return LDNS_STATUS_SYNTAX_EMPTY;
  22. + }
  23. /* Lose the overmeasure */
  24. data = LDNS_XREALLOC(dp = data, uint8_t, length);
  25. if (! data) {
  26. --
  27. 2.9.5