1. ==21536== Conditional jump or move depends on uninitialised value(s)
  2. ==21536== at 0x40164A1: (within /lib/ld-2.11.1.so)
  3. ==21536== by 0x4007C04: (within /lib/ld-2.11.1.so)
  4. ==21536== by 0x4002A2C: (within /lib/ld-2.11.1.so)
  5. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  6. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  7. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  8. ==21536==
  9. ==21536== Conditional jump or move depends on uninitialised value(s)
  10. ==21536== at 0x40164AC: (within /lib/ld-2.11.1.so)
  11. ==21536== by 0x4007C04: (within /lib/ld-2.11.1.so)
  12. ==21536== by 0x4002A2C: (within /lib/ld-2.11.1.so)
  13. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  14. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  15. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  16. --21536-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x55
  17. --21536-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x55
  18. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  19. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  20. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  21. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  22. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  23. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  24. --21536-- DWARF2 CFI reader: unhandled CFI instruction 0:10
  25. ==21536==
  26. ==21536== Conditional jump or move depends on uninitialised value(s)
  27. ==21536== at 0x400B217: (within /lib/ld-2.11.1.so)
  28. ==21536== by 0x40031D0: (within /lib/ld-2.11.1.so)
  29. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  30. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  31. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  32. ==21536==
  33. ==21536== Conditional jump or move depends on uninitialised value(s)
  34. ==21536== at 0x400AF0F: (within /lib/ld-2.11.1.so)
  35. ==21536== by 0x40031D0: (within /lib/ld-2.11.1.so)
  36. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  37. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  38. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  39. ==21536==
  40. ==21536== Conditional jump or move depends on uninitialised value(s)
  41. ==21536== at 0x400B27A: (within /lib/ld-2.11.1.so)
  42. ==21536== by 0x40031D0: (within /lib/ld-2.11.1.so)
  43. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  44. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  45. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  46. ==21536==
  47. ==21536== Conditional jump or move depends on uninitialised value(s)
  48. ==21536== at 0x400A5DE: (within /lib/ld-2.11.1.so)
  49. ==21536== by 0x40030FE: (within /lib/ld-2.11.1.so)
  50. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  51. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  52. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  53. ==21536==
  54. ==21536== Conditional jump or move depends on uninitialised value(s)
  55. ==21536== at 0x400A5E6: (within /lib/ld-2.11.1.so)
  56. ==21536== by 0x40030FE: (within /lib/ld-2.11.1.so)
  57. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  58. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  59. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  60. ==21536==
  61. ==21536== Conditional jump or move depends on uninitialised value(s)
  62. ==21536== at 0x400AF0F: (within /lib/ld-2.11.1.so)
  63. ==21536== by 0x40030FE: (within /lib/ld-2.11.1.so)
  64. ==21536== by 0x4014206: (within /lib/ld-2.11.1.so)
  65. ==21536== by 0x4000C6C: (within /lib/ld-2.11.1.so)
  66. ==21536== by 0x4000856: (within /lib/ld-2.11.1.so)
  67. ==21536==
  68. ==21536== Invalid read of size 8
  69. ==21536== at 0x40B4785: (within /lib/tls/i686/cmov/libc-2.11.1.so)
  70. ==21536== by 0x8049EFB: main (vcutil.c:496)
  71. ==21536== Address 0x419d1b0 is 8 bytes before a block of size 120 alloc'd
  72. ==21536== at 0x4025D2E: malloc (vg_replace_malloc.c:207)
  73. ==21536== by 0x409DF9D: getdelim (in /lib/tls/i686/cmov/libc-2.11.1.so)
  74. ==21536== by 0x408F3A2: getline (in /lib/tls/i686/cmov/libc-2.11.1.so)
  75. ==21536== by 0x804947C: getUnfolded (vcutil.c:299)
  76. ==21536== by 0x8049EFB: main (vcutil.c:496)
  77. ==21536==
  78. ==21536== Conditional jump or move depends on uninitialised value(s)
  79. ==21536== at 0x40B47AD: (within /lib/tls/i686/cmov/libc-2.11.1.so)
  80. ==21536== by 0x8049EFB: main (vcutil.c:496)
  81. ==21536==
  82. ==21536== Conditional jump or move depends on uninitialised value(s)
  83. ==21536== at 0x8049524: getUnfolded (vcutil.c:307)
  84. ==21536== by 0x8049EFB: main (vcutil.c:496)
  85.  
  86. --21536-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x55
  87.  
  88. VcStatus getUnfolded (FILE *const vcf, char **const buff) {
  89.  
  90. //int const buffSize = 30;
  91. size_t lineSize = 0;
  92. int done = 0; //Set to one if the next line checked does not entail unfolding
  93. static char* queue = NULL; //A queue to store the next line read in
  94. static int lineNum = 0;
  95. char* buffer = NULL; //The dynamic memory that will be linked to buf
  96. int valid_line = 0; //Set to one if the line contains characters other then whitespace
  97. char* temp; //Used to point to the location of rn in the buffer
  98.  
  99. VcStatus error; //Initialize VcStatus with appropriate values
  100. error.code = OK;
  101. error.linefrom = lineNum;
  102. error.lineto = 0;
  103.  
  104. //Special case for resetting getUnfolded()
  105. if (vcf == NULL){
  106. lineNum = 0;
  107. if (queue != NULL) queue = NULL;
  108. error.linefrom = 0;
  109. error.lineto = 0;
  110. return error;
  111. }
  112.  
  113. //Copies any string contained in queue from last time into buffer
  114. if (queue != NULL) {
  115. buffer = malloc (strlen (queue)+1);
  116. strcpy (buffer, queue);
  117. strcpy (queue, "");
  118. }
  119.  
  120. //If the end of file has been reached, last line is returned.
  121. if (feof (vcf) != 0) {
  122. queue = NULL;
  123. lineNum += 1;
  124. if (buffer != NULL) {
  125. if (strcmp (buffer, "") != 0)*buff = buffer;
  126. }
  127. else *buff = NULL;
  128. return error;
  129. }
  130.  
  131. while (done == 0) {
  132.  
  133. //Gets a new line from the vcf file, and returns null if there is no more data to be returned
  134. getline (&queue, &lineSize, vcf);
  135.  
  136. if (ferror(vcf) != 0) {
  137. error.code = IOERR;
  138. return error;
  139. }
  140.  
  141. //Sets valid_line to 1 if the line read in contains any characters other then whitespace
  142. for (int i = 0; i < strlen (queue); i++){
  143. if (queue[i] != 'r' && queue[i] != 'n' && queue[i] != ' ' && queue[i] != 't') valid_line = 1;
  144. }
  145.  
  146. if (feof (vcf) && valid_line == 0) {
  147. queue = NULL;
  148. break;
  149. }
  150.  
  151. if (valid_line == 1){
  152. //Finds the 'internet standard' newline and replaces it with a null terminator
  153. temp = strstr (queue, "rn");
  154. if (temp != NULL) strcpy (temp, "");
  155.  
  156. //Sets the buffer equal to contents of queue and resets queue if buffer is empty
  157. if (buffer == NULL) {
  158.  
  159. buffer = malloc (strlen (queue)+1);
  160. lineNum = lineNum + 1;
  161. strcpy (buffer, queue);
  162. strcpy (queue, "");
  163.  
  164. //Checks for leading whitespace to indicate a folded line, and unfolds
  165. }else if (queue [0] == ' ' || queue [0] == 't') {
  166.  
  167. lineNum = lineNum + 1;
  168. buffer = realloc (buffer, strlen (buffer)+strlen (queue)+2);
  169. strcat (buffer, queue+1);
  170. strcpy (queue, "");
  171.  
  172. //If both conditions above are false, buffer contains the next valid line
  173. }else{
  174.  
  175. error.lineto = lineNum;
  176. lineNum += 1;
  177. done = 1;
  178.  
  179. }
  180. }
  181. }
  182.  
  183. *buff = buffer;
  184.  
  185. return error;
  186.  
  187. }
  188.  
  189. int main () {
  190.  
  191. FILE* fp = fopen ("test.vcf", "r");
  192.  
  193. char * buff;
  194.  
  195. getUnfolded (fp, &buff);
  196.  
  197. }