diff options
| author | Po Lu | 2022-03-24 01:50:18 +0000 |
|---|---|---|
| committer | Po Lu | 2022-03-24 01:50:18 +0000 |
| commit | d81df9e44933d5b4d386e29d953055dfc029e742 (patch) | |
| tree | 9531a909811c1659bb62d1ecbce7570686b8cf54 /src | |
| parent | 17393c0db0fbd4ba9b7ddcdc668974ef8a65107d (diff) | |
| download | emacs-d81df9e44933d5b4d386e29d953055dfc029e742.tar.gz emacs-d81df9e44933d5b4d386e29d953055dfc029e742.zip | |
Fix copying font names around on Haiku
* src/haiku_font_support.cc (font_style_to_flags)
(haiku_font_fill_pattern, BFont_open_pattern)
(BFont_populate_fixed_family, BFont_populate_plain_family):
* src/haiku_support.cc (be_get_version_string):
* src/haikufont.c (haikufont_spec_or_entity_to_pattern): Stop
assuming patterns were allocated by xzalloc.
Diffstat (limited to 'src')
| -rw-r--r-- | src/haiku_font_support.cc | 6 | ||||
| -rw-r--r-- | src/haiku_support.cc | 7 | ||||
| -rw-r--r-- | src/haikufont.c | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc index 549c54d8649..fd41ee71f04 100644 --- a/src/haiku_font_support.cc +++ b/src/haiku_font_support.cc | |||
| @@ -289,6 +289,7 @@ font_style_to_flags (char *st, struct haiku_font_pattern *pattern) | |||
| 289 | pattern->specified |= FSPEC_STYLE; | 289 | pattern->specified |= FSPEC_STYLE; |
| 290 | std::strncpy ((char *) &pattern->style, st, | 290 | std::strncpy ((char *) &pattern->style, st, |
| 291 | sizeof pattern->style - 1); | 291 | sizeof pattern->style - 1); |
| 292 | pattern->style[sizeof pattern->style - 1] = '\0'; | ||
| 292 | } | 293 | } |
| 293 | 294 | ||
| 294 | free (style); | 295 | free (style); |
| @@ -411,6 +412,7 @@ haiku_font_fill_pattern (struct haiku_font_pattern *pattern, | |||
| 411 | pattern->specified |= FSPEC_FAMILY; | 412 | pattern->specified |= FSPEC_FAMILY; |
| 412 | std::strncpy (pattern->family, family, | 413 | std::strncpy (pattern->family, family, |
| 413 | sizeof pattern->family - 1); | 414 | sizeof pattern->family - 1); |
| 415 | pattern->family[sizeof pattern->family - 1] = '\0'; | ||
| 414 | pattern->specified |= FSPEC_SPACING; | 416 | pattern->specified |= FSPEC_SPACING; |
| 415 | pattern->mono_spacing_p = flags & B_IS_FIXED; | 417 | pattern->mono_spacing_p = flags & B_IS_FIXED; |
| 416 | } | 418 | } |
| @@ -534,6 +536,8 @@ BFont_open_pattern (struct haiku_font_pattern *pat, void **font, float size) | |||
| 534 | if (!(pat->specified & FSPEC_FAMILY)) | 536 | if (!(pat->specified & FSPEC_FAMILY)) |
| 535 | return 1; | 537 | return 1; |
| 536 | strncpy (name, pat->family, sizeof name - 1); | 538 | strncpy (name, pat->family, sizeof name - 1); |
| 539 | name[sizeof name - 1] = '\0'; | ||
| 540 | |||
| 537 | sty_count = count_font_styles (name); | 541 | sty_count = count_font_styles (name); |
| 538 | 542 | ||
| 539 | if (!sty_count && | 543 | if (!sty_count && |
| @@ -603,6 +607,7 @@ BFont_populate_fixed_family (struct haiku_font_pattern *ptn) | |||
| 603 | 607 | ||
| 604 | ptn->specified |= FSPEC_FAMILY; | 608 | ptn->specified |= FSPEC_FAMILY; |
| 605 | strncpy (ptn->family, f, sizeof ptn->family - 1); | 609 | strncpy (ptn->family, f, sizeof ptn->family - 1); |
| 610 | ptn->family[sizeof ptn->family - 1] = '\0'; | ||
| 606 | } | 611 | } |
| 607 | 612 | ||
| 608 | void | 613 | void |
| @@ -614,6 +619,7 @@ BFont_populate_plain_family (struct haiku_font_pattern *ptn) | |||
| 614 | 619 | ||
| 615 | ptn->specified |= FSPEC_FAMILY; | 620 | ptn->specified |= FSPEC_FAMILY; |
| 616 | strncpy (ptn->family, f, sizeof ptn->family - 1); | 621 | strncpy (ptn->family, f, sizeof ptn->family - 1); |
| 622 | ptn->family[sizeof ptn->family - 1] = '\0'; | ||
| 617 | } | 623 | } |
| 618 | 624 | ||
| 619 | int | 625 | int |
diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 24009c0ef6a..5ad3c7c794d 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc | |||
| @@ -3395,6 +3395,8 @@ void | |||
| 3395 | be_get_version_string (char *version, int len) | 3395 | be_get_version_string (char *version, int len) |
| 3396 | { | 3396 | { |
| 3397 | std::strncpy (version, "Unknown Haiku release", len - 1); | 3397 | std::strncpy (version, "Unknown Haiku release", len - 1); |
| 3398 | version[len - 1] = '\0'; | ||
| 3399 | |||
| 3398 | BPath path; | 3400 | BPath path; |
| 3399 | if (find_directory (B_BEOS_LIB_DIRECTORY, &path) == B_OK) | 3401 | if (find_directory (B_BEOS_LIB_DIRECTORY, &path) == B_OK) |
| 3400 | { | 3402 | { |
| @@ -3408,7 +3410,10 @@ be_get_version_string (char *version, int len) | |||
| 3408 | && appFileInfo.GetVersionInfo (&versionInfo, | 3410 | && appFileInfo.GetVersionInfo (&versionInfo, |
| 3409 | B_APP_VERSION_KIND) == B_OK | 3411 | B_APP_VERSION_KIND) == B_OK |
| 3410 | && versionInfo.short_info[0] != '\0') | 3412 | && versionInfo.short_info[0] != '\0') |
| 3411 | std::strncpy (version, versionInfo.short_info, len - 1); | 3413 | { |
| 3414 | std::strncpy (version, versionInfo.short_info, len - 1); | ||
| 3415 | version[len - 1] = '\0'; | ||
| 3416 | } | ||
| 3412 | } | 3417 | } |
| 3413 | } | 3418 | } |
| 3414 | 3419 | ||
diff --git a/src/haikufont.c b/src/haikufont.c index 5099285f100..b9f6dc2fe8e 100644 --- a/src/haikufont.c +++ b/src/haikufont.c | |||
| @@ -437,6 +437,7 @@ haikufont_spec_or_entity_to_pattern (Lisp_Object ent, | |||
| 437 | strncpy ((char *) &ptn->style, | 437 | strncpy ((char *) &ptn->style, |
| 438 | SSDATA (SYMBOL_NAME (tem)), | 438 | SSDATA (SYMBOL_NAME (tem)), |
| 439 | sizeof ptn->style - 1); | 439 | sizeof ptn->style - 1); |
| 440 | ptn->style[sizeof ptn->style - 1] = '\0'; | ||
| 440 | } | 441 | } |
| 441 | 442 | ||
| 442 | tem = FONT_SLANT_SYMBOLIC (ent); | 443 | tem = FONT_SLANT_SYMBOLIC (ent); |
| @@ -475,6 +476,7 @@ haikufont_spec_or_entity_to_pattern (Lisp_Object ent, | |||
| 475 | strncpy ((char *) &ptn->family, | 476 | strncpy ((char *) &ptn->family, |
| 476 | SSDATA (SYMBOL_NAME (tem)), | 477 | SSDATA (SYMBOL_NAME (tem)), |
| 477 | sizeof ptn->family - 1); | 478 | sizeof ptn->family - 1); |
| 479 | ptn->family[sizeof ptn->family - 1] = '\0'; | ||
| 478 | } | 480 | } |
| 479 | 481 | ||
| 480 | tem = assq_no_quit (QCscript, AREF (ent, FONT_EXTRA_INDEX)); | 482 | tem = assq_no_quit (QCscript, AREF (ent, FONT_EXTRA_INDEX)); |