I created a function - primarily to remove quotes - that removes the first and last character from a string if the character sent to the function matches those first and last of the sent string. However, Since I end up incrementing a pointer I was wondering if I had sent the function an allocated array (say a "char String[100]") and the first and last character are removed would trying to access element 99 cause a memory leak?
Code:
int Remove_Outer
(
char *String,
const char Outer
){
int Last_Index = strlen(String) - 1;
if(Last_Index < 0)
return FAILURE;
if(String[0] != Outer || String[Last_Index] != Outer)
return FAILURE;
String[Last_Index] = '\0';
String++; /* May cause memory leak here */
return SUCCESS;
}