gallivm: ensure string is null-terminated instead of assert()ing
authorEric Engestrom <eric.engestrom@intel.com>
Fri, 21 Sep 2018 11:00:33 +0000 (12:00 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Tue, 25 Sep 2018 10:39:30 +0000 (11:39 +0100)
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
src/gallium/auxiliary/gallivm/lp_bld_printf.c

index 575ebdfdf65b7fd43b9404c70eda25a8f1901cb4..53c4d3cde41e4677abdb2c7335bca837a8c7aeea 100644 (file)
@@ -108,9 +108,7 @@ lp_build_print_value(struct gallivm_state *gallivm,
       type_fmt[5] = '\0';
    } else if (type_kind == LLVMIntegerTypeKind) {
       if (LLVMGetIntTypeWidth(type_ref) == 64) {
-         unsigned flen = strlen(PRId64);
-         assert(flen <= 3);
-         strncpy(type_fmt + 2, PRId64, flen);
+         util_snprintf(type_fmt + 2, 3, "%s", PRId64);
       } else if (LLVMGetIntTypeWidth(type_ref) == 8) {
          type_fmt[2] = 'u';
       } else {