Fix few memory bugs

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-23 16:46:45 +01:00
parent 81b0623a6c
commit 36b71abfaa

View file

@ -243,6 +243,9 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
{
int column;
if (linep >= screen->lines + screen->num_lines)
break;
for (column = 0;
column <= linep->len
&& y < grub_term_num_entries (term_screen->term);
@ -337,7 +340,7 @@ insert_string (struct screen *screen, char *s, int update)
screen->num_lines++;
screen->lines = grub_realloc (screen->lines,
screen->num_lines
* sizeof (struct line));
* sizeof (screen->lines[0]));
if (! screen->lines)
return 0;
@ -1021,6 +1024,8 @@ complete (struct screen *screen, int continuous, int update)
linep->buf[screen->column] = saved_char;
if (completion_buffer.buf)
{
buflen = grub_strlen (completion_buffer.buf);
ucs4 = grub_malloc (sizeof (grub_uint32_t) * (buflen + 1));
@ -1040,8 +1045,10 @@ complete (struct screen *screen, int continuous, int update)
for (i = 0; i < screen->nterms; i++)
{
int num_sections = ((completion_buffer.len
+ grub_term_width (screen->terms[i].term) - 8 - 1)
/ (grub_term_width (screen->terms[i].term) - 8));
+ grub_term_width (screen->terms[i].term)
- 8 - 1)
/ (grub_term_width (screen->terms[i].term)
- 8));
grub_uint32_t *endp;
grub_uint16_t pos;
grub_uint32_t *p = ucs4;
@ -1101,6 +1108,7 @@ complete (struct screen *screen, int continuous, int update)
grub_putcode (GRUB_TERM_DISP_RIGHT, screen->terms[i].term);
grub_term_gotoxy (screen->terms[i].term, pos >> 8, pos & 0xFF);
}
}
if (insert)
{