bash51-005 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 5.1
  4. Patch-ID: bash51-005
  5. Bug-Reported-by: Alexander Mescheryakov <alexander.s.m@gmail.com>,
  6. konsolebox <konsolebox@gmail.com>
  7. Bug-Reference-ID: <5ffd7f3d.1c69fb81.dee25.166c@mx.google.com>,
  8. <CAJnmqwaVs7M6NBqZzcHy5c2+yHkTEg7p+o8ZWuA7sN+6N1q4CA@mail.gmail.com>
  9. Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2021-01/msg00082.html,
  10. https://lists.gnu.org/archive/html/bug-bash/2021-04/msg00160.html
  11. Bug-Description:
  12. Fix two memory leaks when assigning arrays using compound assignment syntax.
  13. Patch (apply with `patch -p0'):
  14. *** ../bash-5.1-patched/subst.c 2020-12-16 17:01:32.000000000 -0500
  15. --- subst.c 2021-01-24 17:48:40.000000000 -0500
  16. ***************
  17. *** 11674,11677 ****
  18. --- 11674,11679 ----
  19. value = string_list (l);
  20. + dispose_words (l);
  21. +
  22. wlen = STRLEN (value);
  23. *** ../bash-5.1-patched/arrayfunc.c 2020-12-16 17:01:32.000000000 -0500
  24. --- arrayfunc.c 2021-04-19 16:43:09.000000000 -0400
  25. ***************
  26. *** 565,574 ****
  27. WORD_LIST *list;
  28. char *akey, *aval, *k, *v;
  29. - int free_aval;
  30. for (list = nlist; list; list = list->next)
  31. {
  32. - free_aval = 0;
  33. -
  34. k = list->word->word;
  35. v = list->next ? list->next->word->word : 0;
  36. --- 565,571 ----
  37. ***************
  38. *** 578,583 ****
  39. akey = expand_assignment_string_to_string (k, 0);
  40. - aval = expand_assignment_string_to_string (v, 0);
  41. -
  42. if (akey == 0 || *akey == 0)
  43. {
  44. --- 575,578 ----
  45. ***************
  46. *** 586,599 ****
  47. continue;
  48. }
  49. if (aval == 0)
  50. {
  51. aval = (char *)xmalloc (1);
  52. aval[0] = '\0'; /* like do_assignment_internal */
  53. - free_aval = 1;
  54. }
  55. bind_assoc_var_internal (var, h, akey, aval, flags);
  56. ! if (free_aval)
  57. ! free (aval);
  58. }
  59. }
  60. --- 581,594 ----
  61. continue;
  62. }
  63. +
  64. + aval = expand_assignment_string_to_string (v, 0);
  65. if (aval == 0)
  66. {
  67. aval = (char *)xmalloc (1);
  68. aval[0] = '\0'; /* like do_assignment_internal */
  69. }
  70. bind_assoc_var_internal (var, h, akey, aval, flags);
  71. ! free (aval);
  72. }
  73. }
  74. *** ../bash-5.1/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
  75. --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
  76. ***************
  77. *** 26,30 ****
  78. looks for to find the patch level (for the sccs version string). */
  79. ! #define PATCHLEVEL 4
  80. #endif /* _PATCHLEVEL_H_ */
  81. --- 26,30 ----
  82. looks for to find the patch level (for the sccs version string). */
  83. ! #define PATCHLEVEL 5
  84. #endif /* _PATCHLEVEL_H_ */