fix a small memory leak issue in waves_callback(), variable curr_sim_type, fix random clipping (due to uninitialized var instead of rect coordinates) in ps_filledrect()

This commit is contained in:
stefan schippers 2025-04-17 15:46:33 +02:00
parent c91aff2abd
commit 21dbd0e340
3 changed files with 5 additions and 4 deletions

View File

@ -907,9 +907,9 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
int same_sim_type = 0;
char *curr_sim_type = NULL;
r = &xctx->rect[GRIDLAYER][i];
my_strdup2(_ALLOC_ID_, &curr_sim_type, get_tok_value(r->prop_ptr, "sim_type", 0));
need_redraw = 0;
if( !(r->flags & 1) ) continue; /* 1: graph; 3: graph_unlocked */
my_strdup2(_ALLOC_ID_, &curr_sim_type, get_tok_value(r->prop_ptr, "sim_type", 0));
gr->gx1 = gr->master_gx1;
gr->gx2 = gr->master_gx2;
gr->gw = gr->master_gw;

View File

@ -572,7 +572,7 @@ static void ps_filledrect(int gc, double rectx1,double recty1,double rectx2,doub
y1=Y_TO_PS(recty1);
x2=X_TO_PS(rectx2);
y2=Y_TO_PS(recty2);
if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&tmp,&tmp,&tmp,&tmp) )
if(rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2))
{
psdash = dash / xctx->zoom;
if(dash) {
@ -1233,7 +1233,7 @@ void create_ps(char **psfile, int what, int fullzoom, int eps)
fprintf(errfp, "ps_draw(): can not create tmpfile %s\n", *psfile);
return;
}
setbuf(fd, NULL); /*To prevent buffer errors, still investigating cause. */
/* setbuf(fd, NULL); */ /* To prevent buffer errors, still investigating cause. */
}
ps_colors=my_calloc(_ALLOC_ID_, cadlayers, sizeof(Ps_color));
if(ps_colors==NULL){

View File

@ -3909,7 +3909,8 @@ const char *translate(int inst, const char* s)
#ifdef __unix__
if(get_sp_cur) {
regfree(get_sp_cur);
get_sp_cur = NULL;
/* get_sp_cur = NULL; */
my_free(_ALLOC_ID_, &get_sp_cur);
}
#endif
}