[hackers] [scc] [cc1] Fix content() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 9 Aug 2016 14:25:44 +0200 (CEST)

commit 058e5104f68f1a0d1a0da305c7e730b2d5adb392
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Aug 9 14:09:29 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Aug 9 14:09:29 2016 +0200

    [cc1] Fix content()
    
    With previous version of the code content() had no problems
    receiving something different to a pointer, but, with the current
    this is not true anymore. If we receive an array then it means
    that we have a problem somewhere.

diff --git a/cc1/expr.c b/cc1/expr.c
index 21af200..138ad48 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -494,10 +494,9 @@ free_np:
 static Node *
 content(char op, Node *np)
 {
- switch (BTYPE(np)) {
- case ARY:
- case FTN:
- case PTR:
+ if (BTYPE(np) != PTR) {
+ errorp("invalid argument of memory indirection");
+ } else {
                 if (np->op == OADDR) {
                         Node *new = np->left;
                         new->type = np->type->type;
_AT_@ -507,10 +506,8 @@ content(char op, Node *np)
                         np = node(op, np->type->type, np, NULL);
                 }
                 np->flags |= NLVAL;
- return np;
- default:
- error("invalid argument of memory indirection");
         }
+ return np;
 }
 
 static Node *
Received on Tue Aug 09 2016 - 14:25:44 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 09 2016 - 14:36:26 CEST