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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1, 1.6.2, 1.7.0
    • Fix Version/s: 1.6.2, 1.7.0
    • Component/s: c
    • Labels:
      None
    • Environment:

      All. Currently using gcc 4.6.1 on Ubuntu 11.10.

    • Release Note:
      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

          Activity

            People

            • Assignee:
              dcreager Douglas Creager
              Reporter:
              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