Do functions leak memory if the return is in a middle of something?

I just put a return instruction in a middle of an while/if test. Does it leak memory? By the way, sorry about Finnish names in the variables. I am reinventing the GSM wheel and I don't like at like at all.

int read_sms()
{
int varao, varak, varaln, varaf, loppu;  
char merkki[2];
int laskuri;

strcpy(viesti,'\0');
strcpy(merkki,'\0');

Serial1.print("AT+CMGRD=0");
Serial1.print('\r');
Serial1.print('\n');

loppu=0;
varao=0;
varak=0;
varaln=0;
laskuri=0;

while (loppu!=1)
{
while(Serial1.available() > 0 )
{
varaf = Serial1.read();
laskuri++;
varao=varak;
varak=varaln;
varaln=varaf;
varaf=sprintf (merkki,"%c",varaf);
if (varaln=='\r' && varao=='O' && varak=='K')
{
loppu=1;
}
//error, no more messages
if (laskuri==22 && varao=='E' && varak=='R')
{
loppu=1;
 Serial.println("error no more msg");
 //is this bad
 return 0;
}
}
}
strcat(viesti, '\0');
return laskuri;
}

No.

Mark

If you have any evidence that it does, you should post it as a bug.

KenF:
If you have any evidence that it does, you should post it as a bug.

I sure will. But it is better to find the bugs now than later.

LMI:
I sure will. But it is better to find the bugs now than later.

You can assume that this bug doesn't exist.

I can see bugs and design errors in you're code but they are yours and NOT C/C++ or IDE bugs. Try laying out your code (which is some thing you should do before posting in any case).

Mark

Hint: Here are the first two bugs

  strcpy(viesti,'\0');
  strcpy(merkki,'\0');

holmes4:
I can see bugs and design errors in you're code but they are yours and NOT C/C++ or IDE bugs. Try laying out your code (which is some thing you should do before posting in any case).

Mark

Memory leaks may or may not happen, no matter what I'll do elsewhere. There sure are bugs

LMI:
Memory leaks may or may not happen, no matter what I'll do elsewhere. There sure are bugs

So, fix the bugs in the snippet you've posted. You've got the clues.