Ver código fonte

* 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 18 anos atrás
pai
commit
8450ebe7bc
1 arquivos alterados com 15 adições e 22 exclusões
  1. +15
    -22
      src/main.c

+ 15
- 22
src/main.c Ver arquivo

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




/* Import our buffer as an ansi (color) one */ /* 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) if(input_buffer == NULL)
{ {
printf("Can't load file in libcucul !\n"); printf("Can't load file in libcucul !\n");
@@ -264,7 +264,7 @@ int main (int argc, char **argv)
return -1; return -1;
} }
/* Export given canvas to format we want */ /* 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) if(output_buffer == NULL)
{ {
printf("Can't export file to text !\n"); 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 ! */ /* AHAHAH, THAT'S A COOL PERL INTERPRETER ! */
temp2 = replace(temp, " = <<\"EOC\";", ""); temp2 = replace(temp, " = <<\"EOC\";", "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }
temp2 = replace(temp, " = <<EOC;" , ""); temp2 = replace(temp, " = <<EOC;" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }
temp2 = replace(temp, " = <<EOC" , ""); temp2 = replace(temp, " = <<EOC" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }
temp2 = replace(temp, " = << EOC" , ""); temp2 = replace(temp, " = << EOC" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }
temp2 = replace(temp, "EOC" , ""); temp2 = replace(temp, "EOC" , "");
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }
temp2 = replace(temp, "$eyes" , cacamoo_use_eyes); temp2 = replace(temp, "$eyes" , cacamoo_use_eyes);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }
temp2 = replace(temp, "${eyes}" , cacamoo_use_eyes); temp2 = replace(temp, "${eyes}" , cacamoo_use_eyes);
if(temp2 != temp)
if(temp!=temp2 && temp2 !=NULL)
{ {
free(temp); free(temp);
temp = temp2; temp = temp2;
} }

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

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

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

*size = strlen(temp)+1; *size = strlen(temp)+1;




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



char *replace(char *str, char *oldpiece, const char *newpiece) char *replace(char *str, char *oldpiece, const char *newpiece)
{ {
int str_index, newstr_index, oldpiece_index, end, 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 */ /* Check for another pattern match */
if((c = (char *) strstr(str+str_index, oldpiece)) != NULL) if((c = (char *) strstr(str+str_index, oldpiece)) != NULL)
oldpiece_index = c - str; oldpiece_index = c - str;


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


Carregando…
Cancelar
Salvar