* grub-core/lib/reed_solomon.c (rs_recover): Prevent memory leak.

(main): Close file.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-06-23 20:55:36 +02:00
parent fbc626665f
commit 1abe47dc99
2 changed files with 22 additions and 8 deletions

View file

@ -1,3 +1,8 @@
2011-06-23 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/reed_solomon.c (rs_recover): Prevent memory leak.
(main): Close file.
2011-06-23 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/xnu.c (grub_cpu_xnu_fill_devprop): Don't attempt

View file

@ -265,6 +265,22 @@ rs_recover (gf_single_t *m, grub_size_t s, grub_size_t rs)
syndroms (m, s, rs, sy);
for (i = 0; i < (int) rs; i++)
if (sy[i] != 0)
break;
/* No error detected. */
if (i == (int) rs)
{
#ifndef STANDALONE
free (sigma);
free (errpot);
free (errpos);
free (sy);
#endif
return;
}
{
gf_single_t *eq;
@ -275,14 +291,6 @@ rs_recover (gf_single_t *m, grub_size_t s, grub_size_t rs)
scratch += rs2 * (rs2 + 1) * sizeof (gf_single_t);
#endif
for (i = 0; i < (int) rs; i++)
if (sy[i] != 0)
break;
/* No error detected. */
if (i == (int) rs)
return;
for (i = 0; i < (int) rs2; i++)
for (j = 0; j < (int) rs2 + 1; j++)
eq[i * (rs2 + 1) + j] = sy[i+j];
@ -504,6 +512,7 @@ main (int argc, char **argv)
rs = s / 3;
buf = xmalloc (s + rs + SECTOR_SIZE);
fread (buf, 1, s, in);
fclose (in);
grub_reed_solomon_add_redundancy (buf, s, rs);