aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-06-20 18:38:04 -0700
committerPaul Eggert2011-06-20 18:38:04 -0700
commit25ed6cc39748008e8f95a247d3ece3e063fcc92e (patch)
tree7f33a1a46ca5f85bafaa28eae7d61835fc8be91f
parentdf1f27af9e60e8f223cce0f5e5ac4107d87f982e (diff)
downloademacs-25ed6cc39748008e8f95a247d3ece3e063fcc92e.tar.gz
emacs-25ed6cc39748008e8f95a247d3ece3e063fcc92e.zip
* xfns.c: Don't assume strlen fits in int.
(xic_create_fontsetname, x_window): Use ptrdiff_t, not int.
-rw-r--r--src/ChangeLog3
-rw-r--r--src/xfns.c13
2 files changed, 10 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8c530340927..b1e30e68a0c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,8 @@
12011-06-21 Paul Eggert <eggert@cs.ucla.edu> 12011-06-21 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * xfns.c: Don't assume strlen fits in int.
4 (xic_create_fontsetname, x_window): Use ptrdiff_t, not int.
5
3 * xdisp.c (message_log_check_duplicate): Return intmax_t, 6 * xdisp.c (message_log_check_duplicate): Return intmax_t,
4 not unsigned long, as we prefer signed integers. All callers changed. 7 not unsigned long, as we prefer signed integers. All callers changed.
5 Detect integer overflow in repeat count. 8 Detect integer overflow in repeat count.
diff --git a/src/xfns.c b/src/xfns.c
index 20bfa1df3f0..e98e287f50b 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1883,7 +1883,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1883 /* Make a fontset name from the base font name. */ 1883 /* Make a fontset name from the base font name. */
1884 if (xic_defaut_fontset == base_fontname) 1884 if (xic_defaut_fontset == base_fontname)
1885 { /* There is no base font name, use the default. */ 1885 { /* There is no base font name, use the default. */
1886 int len = strlen (base_fontname) + 2; 1886 ptrdiff_t len = strlen (base_fontname) + 2;
1887 fontsetname = xmalloc (len); 1887 fontsetname = xmalloc (len);
1888 memset (fontsetname, 0, len); 1888 memset (fontsetname, 0, len);
1889 strcpy (fontsetname, base_fontname); 1889 strcpy (fontsetname, base_fontname);
@@ -1896,7 +1896,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1896 - the base font where the charset spec is replaced by -*-*. 1896 - the base font where the charset spec is replaced by -*-*.
1897 - the same but with the family also replaced with -*-*-. */ 1897 - the same but with the family also replaced with -*-*-. */
1898 const char *p = base_fontname; 1898 const char *p = base_fontname;
1899 int i; 1899 ptrdiff_t i;
1900 1900
1901 for (i = 0; *p; p++) 1901 for (i = 0; *p; p++)
1902 if (*p == '-') i++; 1902 if (*p == '-') i++;
@@ -1904,7 +1904,8 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1904 { /* As the font name doesn't conform to XLFD, we can't 1904 { /* As the font name doesn't conform to XLFD, we can't
1905 modify it to generalize it to allcs and allfamilies. 1905 modify it to generalize it to allcs and allfamilies.
1906 Use the specified font plus the default. */ 1906 Use the specified font plus the default. */
1907 int len = strlen (base_fontname) + strlen (xic_defaut_fontset) + 3; 1907 ptrdiff_t len =
1908 strlen (base_fontname) + strlen (xic_defaut_fontset) + 3;
1908 fontsetname = xmalloc (len); 1909 fontsetname = xmalloc (len);
1909 memset (fontsetname, 0, len); 1910 memset (fontsetname, 0, len);
1910 strcpy (fontsetname, base_fontname); 1911 strcpy (fontsetname, base_fontname);
@@ -1913,7 +1914,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1913 } 1914 }
1914 else 1915 else
1915 { 1916 {
1916 int len; 1917 ptrdiff_t len;
1917 const char *p1 = NULL, *p2 = NULL, *p3 = NULL; 1918 const char *p1 = NULL, *p2 = NULL, *p3 = NULL;
1918 char *font_allcs = NULL; 1919 char *font_allcs = NULL;
1919 char *font_allfamilies = NULL; 1920 char *font_allfamilies = NULL;
@@ -1940,7 +1941,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1940 wildcard. */ 1941 wildcard. */
1941 if (*p3 != '*') 1942 if (*p3 != '*')
1942 { 1943 {
1943 int diff = (p2 - p3) - 2; 1944 ptrdiff_t diff = (p2 - p3) - 2;
1944 1945
1945 base = alloca (strlen (base_fontname) + 1); 1946 base = alloca (strlen (base_fontname) + 1);
1946 memcpy (base, base_fontname, p3 - base_fontname); 1947 memcpy (base, base_fontname, p3 - base_fontname);
@@ -2434,7 +2435,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2434 2435
2435 /* Do some needed geometry management. */ 2436 /* Do some needed geometry management. */
2436 { 2437 {
2437 int len; 2438 ptrdiff_t len;
2438 char *tem, shell_position[32]; 2439 char *tem, shell_position[32];
2439 Arg gal[10]; 2440 Arg gal[10];
2440 int gac = 0; 2441 int gac = 0;