Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

yasm: fix segfaults GNU assembler #29388

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Library/Formula/yasm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Yasm < Formula
homepage 'http://yasm.tortall.net/'
url 'http://tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz'
sha256 '768ffab457b90a20a6d895c39749adb547c1b7cb5c108e84b151a838a23ccf31'
revision 1

bottle do
cellar :any
Expand All @@ -23,6 +24,10 @@ class Yasm < Formula
depends_on :python => :optional
depends_on 'Cython' => :python if build.with? 'python'

# Yasm segfaults on some GNU assembler files on OS X
# http://tortall.lighthouseapp.com/projects/78676/tickets/269
patch :DATA

def install
# https://github.com/Homebrew/homebrew/pull/19593
ENV.deparallelize
Expand All @@ -41,3 +46,46 @@ def install
system 'make install'
end
end

__END__
index 96dec82..0ca18d0 100644
--- a/modules/preprocs/gas/gas-preproc.c
+++ b/modules/preprocs/gas/gas-preproc.c
@@ -409,12 +409,14 @@ static int gas_scan(void *preproc, struct tokenval *tokval)
{ "^^", TOKEN_DBL_XOR },
{ "||", TOKEN_DBL_OR }
};
- for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) {
- if (!strcmp(str, ops[i].op)) {
- tokval->t_type = ops[i].token;
- break;
+ if (strlen(str) > 1) {
+ for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) {
+ if (!strncmp(str, ops[i].op, 2)) {
+ tokval->t_type = ops[i].token;
+ break;
+ }
}
- }
+ }
}

if (tokval->t_type != TOKEN_INVALID) {
@@ -427,7 +429,7 @@ static int gas_scan(void *preproc, struct tokenval *tokval)
tokval->t_type = c;

/* Is it a symbol? If so we need to make it a TOKEN_ID. */
- if (isalpha(c) || c == '_' || c == '.') {
+ if (isalpha(c) || c == '_' || c == '.' || c == '%') {
int symbol_length = 1;

c = get_char(pp);
@@ -829,7 +831,7 @@ static int eval_macro(yasm_preproc_gas *pp, int unused, char *args)
skip_whitespace2(&line2);
if (starts_with(line2, ".macro")) {
nesting++;
- } else if (starts_with(line, ".endm") && --nesting == 0) {
+ } else if (starts_with(line2, ".endm") && --nesting == 0) {
return 1;
}
macro->num_lines++;