[hackers] [scc] [cc1] Remove call to strlen() in initialize() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 26 Jan 2016 14:22:10 +0100 (CET)

commit 33d48f1302e23a91f0835080c8b00372051026c4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jan 26 12:46:06 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jan 26 12:46:06 2016 +0100

    [cc1] Remove call to strlen() in initialize()
    
    The result of this call can be obtained from the own type, and in
    some cases ("foo\0") the call to strlen can give incorrect values.

diff --git a/cc1/init.c b/cc1/init.c
index cd3ec1f..1618570 100644
--- a/cc1/init.c
+++ b/cc1/init.c
_AT_@ -120,7 +120,7 @@ initialize(Type *tp)
                         errorp("array of inappropriate type initialized from string constant");
                         goto return_zero;
                 }
- len = strlen(sym->u.s);
+ len = sym->type->n.elem;
                 if (!tp->defined) {
                         tp->defined = 1;
                         tp->n.elem = len+1;
Received on Tue Jan 26 2016 - 14:22:10 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 26 2016 - 14:24:32 CET