History

tccpp.c: Guard against ppfp being NULL

Missed these in e946eb2a4109e0de5f8514457f851897a4824c3e

Vlad Vissoultchev committed 10 years ago

Commit 810a6771 parent 6a49afb2 files · +18 −24Browse files

Unified · Split

2 files
  1. tcc.c +2 −7
  2. tccpp.c +16 −17
tcc.c+2−7
@@ -303,13 +303,8 @@ int main(int argc, char **argv) · 302 unmodified lines
303 tcc_error("could not write '%s'", s->outfile);303 tcc_error("could not write '%s'", s->outfile);
304 }304 }
305 s->dffp = s->ppfp;305 s->dffp = s->ppfp;
306 if (s->dflag == 'M') {306 if (s->dflag == 'M')
307#ifndef TCC_TARGET_PE307 s->ppfp = NULL;
308 s->ppfp = fopen("/dev/null", "w");
309#else
310 s->ppfp = fopen("nul", "w");
311#endif
312 }
313 }308 }
314 309
315 tcc_set_output_type(s, s->output_type);310 tcc_set_output_type(s, s->output_type);
tccpp.c+16−17
@@ -1072,20 +1072,18 @@ static int macro_is_equal(const int *a, const int *b) · 1071 unmodified lines
1072 1072
1073static void pp_line(TCCState *s1, BufferedFile *f, int level)1073static void pp_line(TCCState *s1, BufferedFile *f, int level)
1074{1074{
1075 int d = f->line_num - f->line_ref;1075 if (s1->ppfp) {
1076 if (s1->Pflag == LINE_MACRO_OUTPUT_FORMAT_NONE1076 int d = f->line_num - f->line_ref;
1077 || (level == 0 && f->line_ref && d < 8))1077 if (s1->Pflag == LINE_MACRO_OUTPUT_FORMAT_NONE
1078 {1078 || (level == 0 && f->line_ref && d < 8)) {
1079 while (d > 0)1079 while (d > 0)
1080 fputs("\n", s1->ppfp), --d;1080 fputs("\n", s1->ppfp), --d;
1081 }1081 } else if (s1->Pflag == LINE_MACRO_OUTPUT_FORMAT_STD) {
1082 else1082 fprintf(s1->ppfp, "#line %d \"%s\"\n", f->line_num, f->filename);
1083 if (s1->Pflag == LINE_MACRO_OUTPUT_FORMAT_STD) {1083 } else {
1084 fprintf(s1->ppfp, "#line %d \"%s\"\n", f->line_num, f->filename);1084 fprintf(s1->ppfp, "# %d \"%s\"%s\n", f->line_num, f->filename,
1085 }1085 level > 0 ? " 1" : level < 0 ? " 2" : "");
1086 else {1086 }
1087 fprintf(s1->ppfp, "# %d \"%s\"%s\n", f->line_num, f->filename,
1088 level > 0 ? " 1" : level < 0 ? " 2" : "");
1089 }1087 }
1090 f->line_ref = f->line_num;1088 f->line_ref = f->line_num;
1091}1089}
@@ -3473,16 +3471,17 @@ ST_FUNC int tcc_preprocess(TCCState *s1) · 2381 unmodified lines
3473 continue;3471 continue;
3474 }3472 }
3475 pp_line(s1, file, 0);3473 pp_line(s1, file, 0);
3476 while (spcs)3474 while (s1->ppfp && spcs > 0)
3477 fputs(" ", s1->ppfp), --spcs;3475 fputs(" ", s1->ppfp), --spcs;
3476 spcs = 0;
3478 token_seen = 1;3477 token_seen = 1;
3479 3478
3480 } else if (tok == TOK_LINEFEED) {3479 } else if (tok == TOK_LINEFEED) {
3481 ++file->line_ref;3480 ++file->line_ref;
3482 token_seen = 0;3481 token_seen = 0;
3483 }3482 }
3484 3483 if (s1->ppfp)
3485 fputs(get_tok_str(tok, &tokc), s1->ppfp);3484 fputs(get_tok_str(tok, &tokc), s1->ppfp);
3486 }3485 }
3487 3486
3488 return 0;3487 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t