+2010-12-21 Colin Watson <cjwatson@ubuntu.com>
+
+ * grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone
+ scratch area. Make sure to initialise chosen in standalone mode as
+ well as non-standalone.
+ Reported by: Robert Hooker and Andy Whitcroft.
+ Tested by: Andy Whitcroft.
+
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
* grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by
#ifdef TEST
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
#define xmalloc malloc
#define grub_memset memset
#define grub_memcpy memcpy
#ifndef STANDALONE
#ifdef TEST
-#include <string.h>
-#include <stdlib.h>
typedef unsigned int grub_size_t;
typedef unsigned char grub_uint8_t;
typedef unsigned short grub_uint16_t;
typedef unsigned short grub_uint16_t;
#else
#include <grub/types.h>
+#include <grub/misc.h>
#endif
void
grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs);
#ifndef STANDALONE
chosen = xmalloc (n * sizeof (int));
- grub_memset (chosen, -1, n * sizeof (int));
#else
chosen = (void *) scratch;
- scratch += n;
+ scratch += n * sizeof (int);
#endif
+ for (i = 0; i < n; i++)
+ chosen[i] = -1;
for (i = 0; i < m; i++)
sol[i] = 0;
gauss_eliminate (eq, n, m, chosen);
#ifndef STANDALONE
free (chosen);
#else
- scratch -= n;
+ scratch -= n * sizeof (int);
#endif
}