[Python-checkins] r80742 - python/trunk/Modules/readline.c

Victor Stinner victor.stinner at haypocalc.com
Tue May 4 10:34:22 CEST 2010


Le mardi 04 mai 2010 02:52:42, brett.cannon a écrit :
> Author: brett.cannon
> New Revision: 80742
> 
> Log:
> Strip out extraneous whitespace, cast a some `const char *` to `void *`
>  when passed to free() and make a `char *` to a `const char *` as found by
>  Clang's static analyzer.

On my version of readline (6.1), HIST_ENTRY has no const field:

typedef struct _hist_entry {
  char *line;
  char *timestamp;		/* char * rather than time_t for read/write */
  histdata_t data;
} HIST_ENTRY;

Is it different in your version of readline?

> Modified:
>    python/trunk/Modules/readline.c
> 
> @@ -378,7 +378,7 @@
>  	}
>  	/* free memory allocated for the history entry */
>  	if (entry->line)
> -		free(entry->line);
> +		free((void *)entry->line);
>  	if (entry->data)
>  		free(entry->data);
>  	free(entry);
> @@ -415,7 +415,7 @@
>  	}
>  	/* free memory allocated for the old history entry */
>  	if (old_entry->line)
> -	    free(old_entry->line);
> +	    free((void *)old_entry->line);
>  	if (old_entry->data)
>  	    free(old_entry->data);
>  	free(old_entry);

...

> @@ -1023,17 +1023,17 @@
>  	/* we have a valid line */
>  	n = strlen(p);
>  	if (n > 0) {
> -		char *line;
> +		const char *line;
>  		HISTORY_STATE *state = history_get_history_state();
>  		if (state->length > 0)
>  #ifdef __APPLE__

-- 
Victor Stinner
http://www.haypocalc.com/


More information about the Python-checkins mailing list