Address some valgrind issues
https://codereview.appspot.com/7448051/
git-svn-id: http://skia.googlecode.com/svn/trunk@7966 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkString.h b/include/core/SkString.h
index 4366630..db32dca 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -51,7 +51,7 @@
static inline char *SkStrDup(const char string[]) {
char *ret = (char *) sk_malloc_throw(strlen(string)+1);
- memcpy(ret,string,strlen(string));
+ memcpy(ret,string,strlen(string)+1);
return ret;
}
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 60bae63..5c88441 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -202,8 +202,12 @@
} else {
desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribIndexValue;
}
- desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_AttribIndex);
- desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kTexCoord_AttribIndex);
+ if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
+ desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_AttribIndex);
+ }
+ if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) {
+ desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kTexCoord_AttribIndex);
+ }
#if GR_DEBUG
// verify valid vertex attribute state
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index a859d18..a019415 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -10,6 +10,7 @@
#ifndef GrGpuGL_DEFINED
#define GrGpuGL_DEFINED
+
#include "GrBinHashKey.h"
#include "GrDrawState.h"
#include "GrGpu.h"
@@ -292,7 +293,7 @@
this->setVertexBufferID(0);
}
for (int i = 0; i < fAttribArrayCount; ++i) {
- if (fAttribArrays[i].vertexBufferID() == id) {
+ if (fAttribArrays[i].isVertexBufferIDBound(id)) {
fAttribArrays[i].invalidate();
}
}
@@ -379,7 +380,9 @@
fAttribPointerIsValid = false;
}
- GrGLuint vertexBufferID() const { return fVertexBufferID; }
+ bool isVertexBufferIDBound(GrGLuint id) const {
+ return fAttribPointerIsValid && id == fVertexBufferID;
+ }
private:
bool fEnableIsValid;
bool fAttribPointerIsValid;
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index e60c9ed..41724b6 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -52,6 +52,7 @@
REPORTER_ASSERT(reporter, SkShader::kColor_GradientType == s->asAGradient(NULL));
SkShader::GradientInfo info;
+ info.fColors = NULL;
info.fColorCount = 0;
s->asAGradient(&info);
REPORTER_ASSERT(reporter, 1 == info.fColorCount);