]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ir_value_set_string needs to use a strdup which doesn't return NULL for an emptystring
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 19 Aug 2012 18:35:51 +0000 (20:35 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 19 Aug 2012 18:35:51 +0000 (20:35 +0200)
ir.c
parser.c

diff --git a/ir.c b/ir.c
index 0a6a8dae555691091c7c202a13368fc7e46602e1..37ce2b0c199edd19f6034616091fc90fcf32c4b2 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -749,11 +749,22 @@ bool ir_value_set_field(ir_value *self, ir_value *fld)
     return true;
 }
 
+static char *ir_strdup(const char *str)
+{
+    if (str && !*str) {
+        /* actually dup empty strings */
+        char *out = mem_a(1);
+        *out = 0;
+        return out;
+    }
+    return util_strdup(str);
+}
+
 bool ir_value_set_string(ir_value *self, const char *str)
 {
     if (self->vtype != TYPE_STRING)
         return false;
-    self->constval.vstring = util_strdup(str);
+    self->constval.vstring = ir_strdup(str);
     self->isconst = true;
     return true;
 }
index 06f6d7a37705f29dd8a217c56ec10e90924411bb..109091d6621531627df5dd1c935ad655e61353ed 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -174,7 +174,7 @@ ast_value* parser_const_float_0(parser_t *parser)
     return parser->imm_float_zero;
 }
 
-char *parser_strdup(const char *str)
+static char *parser_strdup(const char *str)
 {
     if (str && !*str) {
         /* actually dup empty strings */