And one more thing:<br /> You define the return value as char*, then you proceed to return "copy" with malloc, but if it fails, you return a const string, which might be free'd. You should malloc this string. char *_string_duplicate(const char *string) { char *copy = (char*) malloc(sizeof(*copy) * (strlen(string) + 1)); if (copy == NULL) { return "Not enough memory for error message"; } strcpy(copy, string); return copy; }