Add parameters validation to glShaderSource() API

According to GLES2.0 Spec., add parameters validataion to
glShaderSource() API.

Change-Id: I5b0e939fd9657ccbb40a13896c8fc74ef02fd085
Signed-off-by: Tina Zhang <tina.zhang@intel.com>
diff --git a/shared/OpenglCodecCommon/GLSharedGroup.cpp b/shared/OpenglCodecCommon/GLSharedGroup.cpp
old mode 100644
new mode 100755
index c7da37a..b079b6d
--- a/shared/OpenglCodecCommon/GLSharedGroup.cpp
+++ b/shared/OpenglCodecCommon/GLSharedGroup.cpp
@@ -240,6 +240,12 @@
     clearObjectMap(m_shaders);
 }
 
+bool GLSharedGroup::isObject(GLuint obj)
+{
+    android::AutoMutex _lock(m_lock);
+    return ((m_shaders.valueFor(obj)!=NULL) || (m_programs.valueFor(obj)!=NULL));
+}
+
 BufferData * GLSharedGroup::getBufferData(GLuint bufferId)
 {
     android::AutoMutex _lock(m_lock);
diff --git a/shared/OpenglCodecCommon/GLSharedGroup.h b/shared/OpenglCodecCommon/GLSharedGroup.h
old mode 100644
new mode 100755
index 61b8f00..6dfcd8f
--- a/shared/OpenglCodecCommon/GLSharedGroup.h
+++ b/shared/OpenglCodecCommon/GLSharedGroup.h
@@ -110,6 +110,7 @@
 public:
     GLSharedGroup();
     ~GLSharedGroup();
+    bool isObject(GLuint obj);
     BufferData * getBufferData(GLuint bufferId);
     void    addBufferData(GLuint bufferId, GLsizeiptr size, void * data);
     void    updateBufferData(GLuint bufferId, GLsizeiptr size, void * data);
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
old mode 100644
new mode 100755
index 80a2cda..90aa61d
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -656,7 +656,9 @@
 {
     GL2Encoder* ctx = (GL2Encoder*)self;
     ShaderData* shaderData = ctx->m_shared->getShaderData(shader);
-    SET_ERROR_IF(!shaderData, GL_INVALID_VALUE);
+    SET_ERROR_IF(!ctx->m_shared->isObject(shader), GL_INVALID_VALUE);
+    SET_ERROR_IF(!shaderData, GL_INVALID_OPERATION);
+    SET_ERROR_IF((count<0), GL_INVALID_VALUE);
 
     int len = glUtilsCalcShaderSourceLen((char**)string, (GLint*)length, count);
     char *str = new char[len + 1];