From fd765f5e62a927439bf5e05cd9f7f349269d78b9 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 2 Dec 2012 18:59:35 +0900 Subject: [PATCH] Fix an ownership problem with line numbers in qfos. --- tools/qfcc/source/obj_file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/obj_file.c b/tools/qfcc/source/obj_file.c index 098820a6b..1a1058721 100644 --- a/tools/qfcc/source/obj_file.c +++ b/tools/qfcc/source/obj_file.c @@ -314,8 +314,12 @@ qfo_from_progs (pr_info_t *pr) qfo_encode_functions (qfo, &def, &reloc, qfo->spaces + qfo_num_spaces, pr->func_head); - qfo->lines = pr->linenos; - qfo->num_lines = pr->num_linenos; + if (pr->num_linenos) { + qfo->lines = malloc (pr->num_linenos * sizeof (pr_lineno_t)); + memcpy (qfo->lines, pr->linenos, + pr->num_linenos * sizeof (pr_lineno_t)); + qfo->num_lines = pr->num_linenos; + } // strings must be done last because encoding defs and functions adds the // names qfo_init_string_space (qfo, &qfo->spaces[qfo_strings_space], pr->strings);