Browse Source

Attempt fixing memory leaks in function handling

dev
Jon Foster 2 years ago
parent
commit
dd5ebfbf5a
2 changed files with 16 additions and 6 deletions
  1. +15
    -6
      bwb_exp.c
  2. +1
    -0
      bwb_var.c

+ 15
- 6
bwb_exp.c View File

@@ -2702,23 +2702,30 @@ buff_read_function (char *buffer, int *position, VariantType * X)
{
/* STRING */
var_make (argn, StringTypeCode);
if ((argn->Value.String =
/* CM-20211223 this is double allocating, squashing the
pointer from the calloc() within var_make(). The RAM! It
be leakin'! */
/*if ((argn->Value.String =
(StringType *) calloc (1, sizeof (StringType))) == NULL)
{
WARN_OUT_OF_MEMORY;
return RESULT_ERROR;
}
}*/
PARAM_LENGTH = T.Length;
/* PARAM_BUFFER = T.Buffer; */
if ((PARAM_BUFFER =
(char *) calloc (T.Length + 1 /* NulChar */ ,
/* CM-20211223 either we keep the buffer instead of making a
new one or we need to free it. See RELEASE_VARIANT below.
I'm unremm'ing PARAM_BUFFER and leaving RELEASE_VARIANT
disabled. */
PARAM_BUFFER = T.Buffer;
/*if ((PARAM_BUFFER =
(char *) calloc (T.Length + 1 /* NulChar *//* ,
sizeof (char))) == NULL)
{
WARN_OUT_OF_MEMORY;
return RESULT_ERROR;
}
bwb_memcpy (PARAM_BUFFER, T.Buffer, T.Length);
PARAM_BUFFER[PARAM_LENGTH] = NulChar;
PARAM_BUFFER[PARAM_LENGTH] = NulChar;*/
/* add type to ParameterTypes */
if (ParameterCount < MAX_FARGS)
{
@@ -2736,6 +2743,8 @@ buff_read_function (char *buffer, int *position, VariantType * X)
{
ParameterCount++;
}
/* CM-20211223 see comment dated the same just above. I chose to
keep the buffer... wondering why these had been rem'd out... */
/* RELEASE_VARIANT( &T ); */
}
while (buff_skip_seperator (buffer, &p));


+ 1
- 0
bwb_var.c View File

@@ -348,6 +348,7 @@ var_free (VariableType * variable)
variable->Value.String[j].length = 0;
}
free (variable->Value.String);
;
variable->Value.String = NULL;
}
}


Loading…
Cancel
Save