[llvm-commits] [llvm] r170968 - /llvm/trunk/lib/Support/YAMLTraits.cpp

David Blaikie dblaikie at gmail.com
Thu Dec 27 11:38:48 PST 2012


On Fri, Dec 21, 2012 at 4:15 PM, Richard Smith
<richard-llvm at metafoo.co.uk> wrote:
> Author: rsmith
> Date: Fri Dec 21 18:15:13 2012
> New Revision: 170968
>
> URL: http://llvm.org/viewvc/llvm-project?rev=170968&view=rev
> Log:
> Don't call back() on an empty SmallVector. Found by -fsanitize=enum!
>
> Modified:
>     llvm/trunk/lib/Support/YAMLTraits.cpp
>
> Modified: llvm/trunk/lib/Support/YAMLTraits.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLTraits.cpp?rev=170968&r1=170967&r2=170968&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/YAMLTraits.cpp (original)
> +++ llvm/trunk/lib/Support/YAMLTraits.cpp Fri Dec 21 18:15:13 2012
> @@ -516,7 +516,7 @@
>
>  void Output::outputUpToEndOfLine(StringRef s) {
>    this->output(s);
> -  if (StateStack.back() != inFlowSeq)
> +  if (StateStack.empty() || StateStack.back() != inFlowSeq)

Would/should this have been caught by some other UB checking? It seems
like back() on an empty SmallVector already be UB? (I assume this
would require more complex checking to track the type currently
occupying the small portion of the SmallVector, so that attempts to
access elements, whwile valid memory addresses, would be diagnosed as
violating aliasing because there was no T constructed in that location
at the time of the cacess)

>      NeedsNewLine = true;
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list