cc: Fix SEGV when there is no build-id section
authorSasha Goldshtein <goldshtn@gmail.com>
Sun, 12 Feb 2017 00:35:14 +0000 (19:35 -0500)
committerSasha Goldshtein <goldshtn@gmail.com>
Sun, 12 Feb 2017 00:35:14 +0000 (19:35 -0500)
src/cc/bcc_elf.c

index 8a5136f..95ff424 100644 (file)
@@ -241,7 +241,7 @@ static int find_debuglink(Elf *e, char **debug_file, unsigned int *crc) {
 
 static int find_buildid(Elf *e, char *buildid) {
   Elf_Data *data = get_section_elf_data(e, ".note.gnu.build-id");
-  if (data->d_size <= 16 || strcmp((char *)data->d_buf + 12, "GNU"))
+  if (!data || data->d_size <= 16 || strcmp((char *)data->d_buf + 12, "GNU"))
     return 0;
 
   char *buf = (char *)data->d_buf + 16;