apps/s_socket.c:287: error: USE_AFTER_FREE
  accessing memory that was invalidated by call to `free()` on line 287.
Showing all 6 steps of the trace


apps/s_socket.c:281:7: invalidation part of the trace starts here
279.   	for (;;)
280.   		{
281.   		if (do_accept(accept_socket,&sock,&name) == 0)
             ^
282.   			{
283.   			SHUTDOWN(accept_socket);

apps/s_socket.c:281:7: variable `name` accessed here
  279.   	for (;;)
  280.   		{
  281.   		if (do_accept(accept_socket,&sock,&name) == 0)
               ^
  282.   			{
  283.   			SHUTDOWN(accept_socket);

apps/s_socket.c:287:21: was invalidated by call to `free()`
  285.   			}
  286.   		i=(*cb)(name,sock, context);
  287.   		if (name != NULL) Free(name);
                             ^
  288.   		SHUTDOWN2(sock);
  289.   		if (i < 0)

apps/s_socket.c:281:7: use-after-lifetime part of the trace starts here
279.   	for (;;)
280.   		{
281.   		if (do_accept(accept_socket,&sock,&name) == 0)
             ^
282.   			{
283.   			SHUTDOWN(accept_socket);

apps/s_socket.c:281:7: variable `name` accessed here
  279.   	for (;;)
  280.   		{
  281.   		if (do_accept(accept_socket,&sock,&name) == 0)
               ^
  282.   			{
  283.   			SHUTDOWN(accept_socket);

apps/s_socket.c:287:21: invalid access occurs here
  285.   			}
  286.   		i=(*cb)(name,sock, context);
  287.   		if (name != NULL) Free(name);
                             ^
  288.   		SHUTDOWN2(sock);
  289.   		if (i < 0)

int do_server(int port, int *ret, int (*cb)(), char *context)
	{
	int sock;
	char *name;
	int accept_socket;
	int i;
	if (!init_server(&accept_socket,port)) return(0);
	if (ret != NULL)
		{
		*ret=accept_socket;
		}
	for (;;)
		{
		if (do_accept(accept_socket,&sock,&name) == 0)
			{
			SHUTDOWN(accept_socket);
			return(0);
			}
		i=(*cb)(name,sock, context);
		if (name != NULL) Free(name);
		SHUTDOWN2(sock);
		if (i < 0)
			{
			SHUTDOWN2(accept_socket);
			return(i);
			}
		}
	}
['int do_server(int port, int *ret, int (*cb)(), char *context)\n\t{\n\tint sock;\n\tchar *name;\n\tint accept_socket;\n\tint i;\n\tif (!init_server(&accept_socket,port)) return(0);\n\tif (ret != NULL)\n\t\t{\n\t\t*ret=accept_socket;\n\t\t}\n\tfor (;;)\n\t\t{\n\t\tif (do_accept(accept_socket,&sock,&name) == 0)\n\t\t\t{\n\t\t\tSHUTDOWN(accept_socket);\n\t\t\treturn(0);\n\t\t\t}\n\t\ti=(*cb)(name,sock, context);\n\t\tif (name != NULL) Free(name);\n\t\tSHUTDOWN2(sock);\n\t\tif (i < 0)\n\t\t\t{\n\t\t\tSHUTDOWN2(accept_socket);\n\t\t\treturn(i);\n\t\t\t}\n\t\t}\n\t}']