Explorar el Código

* Fixed double free in wonderfull perl interpreter

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/cacamoo/trunk@1250 92316355-f0b4-4df1-b90c-862c8a59935f
master
jylam hace 18 años
padre
commit
8450ebe7bc
Se han modificado 1 ficheros con 15 adiciones y 22 borrados
  1. +15
    -22
      src/main.c

+ 15
- 22
src/main.c Ver fichero

@@ -251,7 +251,7 @@ int main (int argc, char **argv)


/* Import our buffer as an ansi (color) one */
input_buffer = cucul_load_memory(buffer, buffer_size);
input_buffer = cucul_load_memory(buffer, buffer_size-1);
if(input_buffer == NULL)
{
printf("Can't load file in libcucul !\n");
@@ -264,7 +264,7 @@ int main (int argc, char **argv)
return -1;
}
/* Export given canvas to format we want */
output_buffer = cucul_export_canvas(canvas, "irc");
output_buffer = cucul_export_canvas(canvas, "ansi");
if(output_buffer == NULL)
{
printf("Can't export file to text !\n");
@@ -368,87 +368,83 @@ char * make_caca_from_file(unsigned int *size)

/* AHAHAH, THAT'S A COOL PERL INTERPRETER ! */
temp2 = replace(temp, " = <<\"EOC\";", "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, " = <<EOC;" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, " = <<EOC" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, " = << EOC" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, "EOC" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, "$eyes" , cacamoo_use_eyes);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, "${eyes}" , cacamoo_use_eyes);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}

temp2 = replace(temp, "$tongue" , cacamoo_use_tongue);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, "${tongue}" , cacamoo_use_tongue);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}

temp2 = replace(temp, "$thoughts" , cacamoo_thoughts);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, "${thoughts}" , cacamoo_thoughts);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}

temp2 = replace(temp, "$the_cow" , (const char*)string);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}
temp2 = replace(temp, "${the_cow}" , (const char*)string);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{
free(temp);
temp = temp2;
}

*size = strlen(temp)+1;


@@ -508,7 +504,6 @@ char *remove_comments(char *str)
return str;
}


char *replace(char *str, char *oldpiece, const char *newpiece)
{
int str_index, newstr_index, oldpiece_index, end,
@@ -553,8 +548,6 @@ char *replace(char *str, char *oldpiece, const char *newpiece)
/* Check for another pattern match */
if((c = (char *) strstr(str+str_index, oldpiece)) != NULL)
oldpiece_index = c - str;


}
/* Copy remaining characters from the right of last matched pattern */
strcpy(newstr+newstr_index, str+str_index);


Cargando…
Cancelar
Guardar