Skip to content

Commit

Permalink
Do not check for NULL before calling free()
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrapha authored and jaromil committed May 30, 2023
1 parent 203c03a commit 8e87196
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/filter/curves/curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
void f0r_destruct(f0r_instance_t instance)
{
curves_instance_t* inst = (curves_instance_t*)instance;
if (inst->bspline) free(inst->bspline);
if(inst->bsplineMap) free(inst->bsplineMap);
if(inst->csplineMap) free(inst->csplineMap);
if(inst->curveMap) free(inst->curveMap);
free(inst->bspline);
free(inst->bsplineMap);
free(inst->csplineMap);
free(inst->curveMap);
free(inst);
}

Expand Down
4 changes: 2 additions & 2 deletions src/filter/delaygrab/delaygrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ DelayGrab::DelayGrab(int wdt, int hgt) {
}

DelayGrab::~DelayGrab() {
if(delaymap) free(delaymap);
free(delaymap);
free(imagequeue);
}

Expand Down Expand Up @@ -271,7 +271,7 @@ void DelayGrab::set_blocksize(int bs) {
delaymapheight = (geo.h)/blocksize;
delaymapsize = delaymapheight*delaymapwidth;

if(delaymap) { free(delaymap); delaymap = NULL; }
free(delaymap);
delaymap = malloc(delaymapsize*4);

createDelaymap(current_mode);
Expand Down
2 changes: 1 addition & 1 deletion src/filter/nervous/nervous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Nervous::Nervous(int wdt, int hgt) {
}

Nervous::~Nervous() {
if(buffer) free(buffer);
free(buffer);
}

void Nervous::_init(int wdt, int hgt) {
Expand Down
6 changes: 1 addition & 5 deletions src/filter/vertigo/vertigo.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
void f0r_destruct(f0r_instance_t instance)
{
vertigo_instance_t* inst = (vertigo_instance_t*)instance;
if(inst->buffer!=NULL)
{
free(inst->buffer);
inst->buffer = NULL;
}
free(inst->buffer);
free(instance);
}

Expand Down

0 comments on commit 8e87196

Please sign in to comment.