diff options
| author | Paul Eggert | 2014-09-23 21:12:37 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-09-23 21:12:37 -0700 |
| commit | 4620e6bccd98625208d8be4d960d24119a20594f (patch) | |
| tree | 6de4ba8eba559a7b844b177e336cbd012fedd22d /src | |
| parent | 7d760fd8f4fd2fb622183106912c34845e280333 (diff) | |
| download | emacs-4620e6bccd98625208d8be4d960d24119a20594f.tar.gz emacs-4620e6bccd98625208d8be4d960d24119a20594f.zip | |
Fix some slow uses and misuses of strcat.
* doc.c (get_doc_string):
* gtkutil.c (get_utf8_string):
* xsmfns.c (x_session_initialize):
Avoid recomputation of string length.
* ftfont.c (ftfont_spec_pattern):
* xfns.c (xic_create_fontsetname):
Don't assume output buffer is initially zero.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/doc.c | 4 | ||||
| -rw-r--r-- | src/ftfont.c | 2 | ||||
| -rw-r--r-- | src/gtkutil.c | 8 | ||||
| -rw-r--r-- | src/xfns.c | 7 | ||||
| -rw-r--r-- | src/xsmfns.c | 6 |
6 files changed, 25 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7f05f6fe21f..0fc4c2b1599 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2014-09-24 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Fix some slow uses and misuses of strcat. | ||
| 4 | * doc.c (get_doc_string): | ||
| 5 | * gtkutil.c (get_utf8_string): | ||
| 6 | * xsmfns.c (x_session_initialize): | ||
| 7 | Avoid recomputation of string length. | ||
| 8 | * ftfont.c (ftfont_spec_pattern): | ||
| 9 | * xfns.c (xic_create_fontsetname): | ||
| 10 | Don't assume output buffer is initially zero. | ||
| 11 | |||
| 1 | 2014-09-23 Paul Eggert <eggert@cs.ucla.edu> | 12 | 2014-09-23 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 13 | ||
| 3 | * lisp.h (lispstpcpy): Rename from lispstrcpy, and act like stpcpy. | 14 | * lisp.h (lispstpcpy): Rename from lispstrcpy, and act like stpcpy. |
| @@ -121,8 +121,8 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition) | |||
| 121 | if (minsize < 8) | 121 | if (minsize < 8) |
| 122 | minsize = 8; | 122 | minsize = 8; |
| 123 | name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); | 123 | name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); |
| 124 | lispstpcpy (name, docdir); | 124 | char *z = lispstpcpy (name, docdir); |
| 125 | strcat (name, SSDATA (file)); | 125 | strcpy (z, SSDATA (file)); |
| 126 | } | 126 | } |
| 127 | else | 127 | else |
| 128 | { | 128 | { |
diff --git a/src/ftfont.c b/src/ftfont.c index 0ab3119365e..4c12ef5d3af 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -804,7 +804,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots | |||
| 804 | *otspec = ftfont_get_open_type_spec (val); | 804 | *otspec = ftfont_get_open_type_spec (val); |
| 805 | if (! *otspec) | 805 | if (! *otspec) |
| 806 | return NULL; | 806 | return NULL; |
| 807 | strcat (otlayout, "otlayout:"); | 807 | strcpy (otlayout, "otlayout:"); |
| 808 | OTF_TAG_STR ((*otspec)->script_tag, otlayout + 9); | 808 | OTF_TAG_STR ((*otspec)->script_tag, otlayout + 9); |
| 809 | script = (*otspec)->script; | 809 | script = (*otspec)->script; |
| 810 | } | 810 | } |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 62f2c1b0682..1f3e1958ede 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -508,16 +508,16 @@ get_utf8_string (const char *str) | |||
| 508 | && err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) | 508 | && err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) |
| 509 | { | 509 | { |
| 510 | memcpy (up, p, bytes_written); | 510 | memcpy (up, p, bytes_written); |
| 511 | sprintf (up + bytes_written, "\\%03o", p[bytes_written]); | 511 | up += bytes_written; |
| 512 | up += bytes_written+4; | 512 | up += sprintf (up, "\\%03o", p[bytes_written]); |
| 513 | p += bytes_written+1; | 513 | p += bytes_written + 1; |
| 514 | g_error_free (err); | 514 | g_error_free (err); |
| 515 | err = NULL; | 515 | err = NULL; |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | if (cp) | 518 | if (cp) |
| 519 | { | 519 | { |
| 520 | strcat (utf8_str, cp); | 520 | strcpy (up, cp); |
| 521 | g_free (cp); | 521 | g_free (cp); |
| 522 | } | 522 | } |
| 523 | if (err) | 523 | if (err) |
diff --git a/src/xfns.c b/src/xfns.c index c2e39b5c0a6..63978c27f46 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -1786,7 +1786,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1786 | len = p - base_fontname + strlen (allcs) + 1; | 1786 | len = p - base_fontname + strlen (allcs) + 1; |
| 1787 | font_allcs = alloca (len); | 1787 | font_allcs = alloca (len); |
| 1788 | memcpy (font_allcs, base_fontname, p - base_fontname); | 1788 | memcpy (font_allcs, base_fontname, p - base_fontname); |
| 1789 | strcat (font_allcs, allcs); | 1789 | strcpy (font_allcs + (p - base_fontname), allcs); |
| 1790 | 1790 | ||
| 1791 | /* Build the font spec that matches all families and | 1791 | /* Build the font spec that matches all families and |
| 1792 | add-styles. */ | 1792 | add-styles. */ |
| @@ -1794,7 +1794,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1794 | font_allfamilies = alloca (len); | 1794 | font_allfamilies = alloca (len); |
| 1795 | strcpy (font_allfamilies, allfamilies); | 1795 | strcpy (font_allfamilies, allfamilies); |
| 1796 | memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1); | 1796 | memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1); |
| 1797 | strcat (font_allfamilies, allcs); | 1797 | strcpy (font_allfamilies + strlen (allfamilies) + (p - p1), allcs); |
| 1798 | 1798 | ||
| 1799 | /* Build the font spec that matches all. */ | 1799 | /* Build the font spec that matches all. */ |
| 1800 | len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; | 1800 | len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; |
| @@ -1802,7 +1802,8 @@ xic_create_fontsetname (const char *base_fontname, int motif) | |||
| 1802 | strcpy (font_all, allfamilies); | 1802 | strcpy (font_all, allfamilies); |
| 1803 | strcat (font_all, all); | 1803 | strcat (font_all, all); |
| 1804 | memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); | 1804 | memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); |
| 1805 | strcat (font_all, allcs); | 1805 | strcpy (font_all + strlen (all) + strlen (allfamilies) + (p - p2), |
| 1806 | allcs); | ||
| 1806 | 1807 | ||
| 1807 | /* Build the actual font set name. */ | 1808 | /* Build the actual font set name. */ |
| 1808 | len = strlen (base_fontname) + strlen (font_allcs) | 1809 | len = strlen (base_fontname) + strlen (font_allcs) |
diff --git a/src/xsmfns.c b/src/xsmfns.c index ed67a7d8e1f..cd4f9ce57fa 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -415,11 +415,11 @@ x_session_initialize (struct x_display_info *dpyinfo) | |||
| 415 | /* This malloc will not be freed, but it is only done once, and hopefully | 415 | /* This malloc will not be freed, but it is only done once, and hopefully |
| 416 | not very large */ | 416 | not very large */ |
| 417 | emacs_program = xmalloc (name_len + 1); | 417 | emacs_program = xmalloc (name_len + 1); |
| 418 | emacs_program[0] = '\0'; | 418 | char *z = emacs_program; |
| 419 | 419 | ||
| 420 | if (! EQ (Vinvocation_directory, Qnil)) | 420 | if (! EQ (Vinvocation_directory, Qnil)) |
| 421 | lispstpcpy (emacs_program, Vinvocation_directory); | 421 | z = lispstpcpy (z, Vinvocation_directory); |
| 422 | strcat (emacs_program, SSDATA (Vinvocation_name)); | 422 | lispstpcpy (z, Vinvocation_name); |
| 423 | 423 | ||
| 424 | /* The SM protocol says all callbacks are mandatory, so set up all | 424 | /* The SM protocol says all callbacks are mandatory, so set up all |
| 425 | here and in the mask passed to SmcOpenConnection. */ | 425 | here and in the mask passed to SmcOpenConnection. */ |