Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-968

Avro C - avro_value_cmp_fast() may return garbage value for AVRO_STRING comparison

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6.1, 1.6.2, 1.7.0
    • 1.6.2, 1.7.0
    • c
    • None
    • All. Currently using gcc 4.6.1 on Ubuntu 11.10.

    • Fix uninitialized variable warning in value.c, by initializing the variables properly.

    Description

      Compiler shows a warning that variables may be used uninitialized in avro_value_cmp_fast():

      /home/user/avro-trunk/lang/c/src/value.c: In function 'avro_value_cmp_fast':
      /home/user/avro-trunk/lang/c/src/value.c:387:13: warning: 'size2' may be used uninitialized in this function [-Wuninitialized]
      /home/user/avro-trunk/lang/c/src/value.c:387:13: warning: 'size1' may be used uninitialized in this function [-Wuninitialized]
      /home/user/avro-trunk/lang/c/src/value.c:388:11: warning: 'buf1' may be used uninitialized in this function [-Wuninitialized]
      /home/user/avro-trunk/lang/c/src/value.c:388:11: warning: 'buf2' may be used uninitialized in this function [-Wuninitialized]

      Examining the file shows that the warnings are real, and the variables size1, buf1, size2, buf2 should be loaded before they are used. The simple fix is to copy matching code from the function avro_value_equal_fast(). I will attach that code in an upcoming patch.

      Cheers,
      Vivek

      Attachments

        1. 0001-AVRO-968.-C-Fixed-avro_value_cmp-on-string-values.patch
          6 kB
          Douglas Creager
        2. AVRO-968.patch
          0.5 kB
          Vivek Nadkarni

        Activity

          People

            dcreager Douglas Creager
            vnadkarni Vivek Nadkarni
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified