Yup, sizeof() includes the space for the \0

This commit is contained in:
Rasmus Lerdorf 2002-08-03 14:09:56 +00:00
parent 02a12b57e9
commit c8bf165242

View File

@ -220,7 +220,7 @@ SAPI_API char *sapi_get_default_content_type(TSRMLS_D)
charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET;
if (strncasecmp(mimetype, "text/", 5) == 0 && *charset) {
int len = strlen(mimetype) + sizeof("; charset=") + strlen(charset)+1;
int len = strlen(mimetype) + sizeof("; charset=") + strlen(charset); /* sizeof() includes \0 */
content_type = emalloc(len);
snprintf(content_type, len, "%s; charset=%s", mimetype, charset);
} else {