Commit d9820113 authored by CDT 1998  Larry Ewing's avatar CDT 1998 Larry Ewing Committed by Larry Ewing
Browse files

Fixed a string allocation problem that failed to account for the trailing

Fri Jul 24 12:01:31 CDT 1998  Larry Ewing  <lewing@gimp.org>

	* app/gdisplay.c (gdisplay_update_cursor): Fixed a string
	allocation problem that failed to account for the trailing \0
	(removed time sensitve calculation/malloc in the process).
parent 69d92241
Fri Jul 24 12:01:31 CDT 1998 Larry Ewing <lewing@gimp.org>
* app/gdisplay.c (gdisplay_update_cursor): Fixed a string
allocation problem that failed to account for the trailing \0
(removed time sensitve calculation/malloc in the process).
Fri Jul 24 01:33:13 PDT 1998 Jay Cox <jaycox@earthlink.net>
* app/vector2d.[ch] Makefile.am: new files for vector math.
......
......@@ -660,13 +660,13 @@ gdisplay_draw_cursor (GDisplay *gdisp)
x+1, y - 7, x+1, y + 7);
}
#define CURSOR_STR_LENGTH 256
void
gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
{
int new_cursor;
char *buffer;
int buffer_size;
int tmp;
char buffer[CURSOR_STR_LENGTH];
int t_x, t_y;
new_cursor = gdisp->draw_cursor && gdisp->proximity;
......@@ -694,36 +694,8 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
}
else
{
buffer_size = 6;
tmp = t_x;
if (tmp < 0)
{
buffer_size++;
tmp *= -1;
}
while (tmp > 9)
{
buffer_size++;
tmp /= 10;
}
tmp = t_y;
if (tmp < 0)
{
buffer_size++;
tmp *= -1;
}
while (tmp > 9)
{
buffer_size++;
tmp /= 10;
}
buffer = malloc(sizeof(char)*buffer_size);
sprintf(buffer, " %d, %d ", t_x, t_y);
g_snprintf(buffer, CURSOR_STR_LENGTH, " %d, %d ", t_x, t_y);
gtk_label_set(GTK_LABEL (gdisp->cursor_label), buffer);
free(buffer);
}
gdisp->have_cursor = new_cursor;
......
......@@ -660,13 +660,13 @@ gdisplay_draw_cursor (GDisplay *gdisp)
x+1, y - 7, x+1, y + 7);
}
#define CURSOR_STR_LENGTH 256
void
gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
{
int new_cursor;
char *buffer;
int buffer_size;
int tmp;
char buffer[CURSOR_STR_LENGTH];
int t_x, t_y;
new_cursor = gdisp->draw_cursor && gdisp->proximity;
......@@ -694,36 +694,8 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
}
else
{
buffer_size = 6;
tmp = t_x;
if (tmp < 0)
{
buffer_size++;
tmp *= -1;
}
while (tmp > 9)
{
buffer_size++;
tmp /= 10;
}
tmp = t_y;
if (tmp < 0)
{
buffer_size++;
tmp *= -1;
}
while (tmp > 9)
{
buffer_size++;
tmp /= 10;
}
buffer = malloc(sizeof(char)*buffer_size);
sprintf(buffer, " %d, %d ", t_x, t_y);
g_snprintf(buffer, CURSOR_STR_LENGTH, " %d, %d ", t_x, t_y);
gtk_label_set(GTK_LABEL (gdisp->cursor_label), buffer);
free(buffer);
}
gdisp->have_cursor = new_cursor;
......
......@@ -660,13 +660,13 @@ gdisplay_draw_cursor (GDisplay *gdisp)
x+1, y - 7, x+1, y + 7);
}
#define CURSOR_STR_LENGTH 256
void
gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
{
int new_cursor;
char *buffer;
int buffer_size;
int tmp;
char buffer[CURSOR_STR_LENGTH];
int t_x, t_y;
new_cursor = gdisp->draw_cursor && gdisp->proximity;
......@@ -694,36 +694,8 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
}
else
{
buffer_size = 6;
tmp = t_x;
if (tmp < 0)
{
buffer_size++;
tmp *= -1;
}
while (tmp > 9)
{
buffer_size++;
tmp /= 10;
}
tmp = t_y;
if (tmp < 0)
{
buffer_size++;
tmp *= -1;
}
while (tmp > 9)
{
buffer_size++;
tmp /= 10;
}
buffer = malloc(sizeof(char)*buffer_size);
sprintf(buffer, " %d, %d ", t_x, t_y);
g_snprintf(buffer, CURSOR_STR_LENGTH, " %d, %d ", t_x, t_y);
gtk_label_set(GTK_LABEL (gdisp->cursor_label), buffer);
free(buffer);
}
gdisp->have_cursor = new_cursor;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment