1
0

010-double-memleak.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. --- classpath-0.99.orig/native/fdlibm/dtoa.c 2007-09-27 05:33:38.000000000 -0700
  2. +++ classpath-0.99/native/fdlibm/dtoa.c 2014-12-21 14:22:42.451713851 -0800
  3. @@ -883,6 +883,16 @@ ret1:
  4. return s0;
  5. }
  6. +void free_Bigints(struct _Jv_Bigint *p)
  7. +{
  8. + struct _Jv_Bigint *l = p;
  9. + while (l)
  10. + {
  11. + struct _Jv_Bigint *next = l->_next;
  12. + free (l);
  13. + l = next;
  14. + }
  15. +}
  16. _VOID
  17. _DEFUN (_dtoa,
  18. @@ -905,16 +915,15 @@ _DEFUN (_dtoa,
  19. p = _dtoa_r (&reent, _d, mode, ndigits, decpt, sign, rve, float_type);
  20. strcpy (buf, p);
  21. - for (i = 0; i < reent._result_k; ++i)
  22. + for (i = 0; i < reent._max_k; ++i)
  23. {
  24. - struct _Jv_Bigint *l = reent._freelist[i];
  25. - while (l)
  26. - {
  27. - struct _Jv_Bigint *next = l->_next;
  28. - free (l);
  29. - l = next;
  30. - }
  31. + free_Bigints(reent._freelist[i]);
  32. }
  33. if (reent._freelist)
  34. free (reent._freelist);
  35. +
  36. + if (reent._result)
  37. + free(reent._result);
  38. +
  39. + free_Bigints(reent._p5s);
  40. }
  41. --- classpath-0.99.orig/native/jni/java-lang/java_lang_VMDouble.c 2008-02-08 09:42:57.000000000 -0800
  42. +++ classpath-0.99/native/jni/java-lang/java_lang_VMDouble.c 2014-12-21 14:35:50.733800626 -0800
  43. @@ -158,6 +158,17 @@ Java_java_lang_VMDouble_longBitsToDouble
  44. return val.d;
  45. }
  46. +static void free_Bigints(struct _Jv_Bigint *p)
  47. +{
  48. + struct _Jv_Bigint *l = p;
  49. + while (l)
  50. + {
  51. + struct _Jv_Bigint *next = l->_next;
  52. + free (l);
  53. + l = next;
  54. + }
  55. +}
  56. +
  57. /**
  58. * Parse a double from a char array.
  59. */
  60. @@ -167,7 +178,7 @@ parseDoubleFromChars(JNIEnv * env, const
  61. char *endptr;
  62. jdouble val = 0.0;
  63. const char *p = buf, *end, *last_non_ws, *temp;
  64. - int ok = 1;
  65. + int i, ok = 1;
  66. #ifdef DEBUG
  67. fprintf (stderr, "java.lang.VMDouble.parseDouble (%s)\n", buf);
  68. @@ -224,6 +235,18 @@ parseDoubleFromChars(JNIEnv * env, const
  69. val = _strtod_r (&reent, p, &endptr);
  70. + for (i = 0; i < reent._max_k; ++i)
  71. + {
  72. + free_Bigints(reent._freelist[i]);
  73. + }
  74. + if (reent._freelist)
  75. + free (reent._freelist);
  76. +
  77. + if (reent._result)
  78. + free (reent._result);
  79. +
  80. + free_Bigints(reent._p5s);
  81. +
  82. #ifdef DEBUG
  83. fprintf (stderr, "java.lang.VMDouble.parseDouble val = %g\n", val);
  84. fprintf (stderr, "java.lang.VMDouble.parseDouble %p != %p ???\n",