Some minor bug fixes (prevent crashes in dana and upon quit)

This commit is contained in:
Nils Faerber 2012-06-17 00:30:46 +02:00
parent 9e2a869871
commit 0100a84c89
2 changed files with 8 additions and 5 deletions

View file

@ -563,14 +563,16 @@ static int separate_params(char *params[], char *pbuf)
static void params_free(char **params)
{
int i;
for (i=0; i < PARAMS_MAX; i++)
if (params[i] != NULL)
free(params[i]);
}
void process_cmd(char *cmdline, int clinep, mwdata_t *mwdata)
{
unsigned char mdata[32];
unsigned int intopt;
unsigned int intopt=0;
char cmd[128], pbuf[128], *params[PARAMS_MAX];
int i, pcnt;
char *inbuf = cmdline;
@ -602,11 +604,9 @@ void process_cmd(char *cmdline, int clinep, mwdata_t *mwdata)
pcnt = 0;
if (strncmp(cmd, "quit", 4) == 0) {
//close(mw_fd);
//exit(0);
/* just in case we quit and show another screen */
mw_update_display(&mwdata->mwdevice, MW_SCREEN_MODE_IDLE, 0);
params_free(params);
// params_free(params);
g_main_loop_quit (mwdata->mloop);
}
if (strncmp(cmd, "help", 4) == 0) {

View file

@ -155,6 +155,9 @@ void mw_buf_draw_pixel(mw_buffer *mwbuf, unsigned int x, unsigned int y, mw_colo
if (clr == MW_TRANSPARENT)
return;
if (x < 0 || x > 128 || y < 0 || y > 128)
return;
*(unsigned char *)(mwbuf->pbuf+((y*mwbuf->res_x)+x)) = clr;
}