view Python/strdup.c @ 79063:2bdc8c8ea42e

Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times
author Christian Heimes <christian@cheimes.de>
date Thu, 20 Sep 2012 12:42:54 +0200
parents f79434ee41fa
children e7f6cef7a4cc
line wrap: on
line source

/* strdup() replacement (from stdwin, if you must know) */

#include "pgenheaders.h"

char *
strdup(const char *str)
{
	if (str != NULL) {
		register char *copy = malloc(strlen(str) + 1);
		if (copy != NULL)
			return strcpy(copy, str);
	}
	return NULL;
}