]> granicus.if.org Git - yasm/commitdiff
re2c: Use tmpfile instead of fixed temporary filename.
authorPeter Johnson <peter@tortall.net>
Mon, 3 Oct 2011 06:20:38 +0000 (23:20 -0700)
committerPeter Johnson <peter@tortall.net>
Mon, 3 Oct 2011 06:20:38 +0000 (23:20 -0700)
This could cause a race condition when running parallel make.

Tracked down by Volker Braun.

[#238 state:resolved]
[#165 state:resolved]

tools/re2c/code.c

index a3341cb4580c752457817826bee2ef559b41278a..8a78eaa03259d66e8105296645944564215726c2 100644 (file)
@@ -844,14 +844,13 @@ void DFA_emit(DFA *d, FILE *o){
     nOrgOline = oline;
     maxFillIndexes = vFillIndexes;
     orgVFillIndexes = vFillIndexes;
-    tmpo = fopen("re2c.tmp", "wt");
+    tmpo = tmpfile();
     for(s = d->head; s; s = s->next){
        int readCh = 0;
        State_emit(s, tmpo, &readCh);
        Go_genGoto(&s->go, tmpo, s, s->next, &readCh);
     }
     fclose(tmpo);
-    remove("re2c.tmp");
     maxFillIndexes = vFillIndexes;
     vFillIndexes = orgVFillIndexes;
     oline = nOrgOline;