]> granicus.if.org Git - yasm/commitdiff
* linemgr.c (yasm_linemap_create): Initialize pointers in initial
authorPeter Johnson <peter@tortall.net>
Sun, 31 Oct 2004 04:18:37 +0000 (04:18 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 31 Oct 2004 04:18:37 +0000 (04:18 -0000)
source_info array.  Unless these are initialized to 0,
yasm_linemap_destroy() attempts to free these (invalid) pointers.

svn path=/trunk/yasm/; revision=1170

libyasm/linemgr.c

index f92f1516fe2042f26a48c9fabaf085c03a296a6b..6cccd598c186d83dcfe3356fed776597cd5ca359 100644 (file)
@@ -120,6 +120,7 @@ yasm_linemap_set(yasm_linemap *linemap, const char *filename,
 yasm_linemap *
 yasm_linemap_create(void)
 {
+    size_t i;
     yasm_linemap *linemap = yasm_xmalloc(sizeof(yasm_linemap));
 
     linemap->filenames = HAMT_create(yasm_internal_error_);
@@ -136,6 +137,10 @@ yasm_linemap_create(void)
     linemap->source_info_size = 2;
     linemap->source_info = yasm_xmalloc(linemap->source_info_size *
                                        sizeof(line_source_info));
+    for (i=0; i<linemap->source_info_size; i++) {
+       linemap->source_info[i].bc = NULL;
+       linemap->source_info[i].source = NULL;
+    }
 
     return linemap;
 }