Custom Fragment and CCRenderTexture, disorted output in cocos2dx 2.x

I created an extension of CCSprite named SampleSprite, which has its own custom shaders. I am getting the texture of a CCRenderTexture rt and passing it to the SampleSprite, which does some shader magic to the texture and then rendering the shaded sprite into the CCRenderTexture again.
or In other words, I take current texture of CCRenderTexture, apply some shader effects to it and then re-render it over the original CCRenderTexture, thus replacing the old texture.
SampleSprite
pSprite1 = SampleSprite::createWithTexture(rt~~>getSprite~~>getTexture);
pSprite1~~>setPosition );
pSprite1~~>setFlipY(true);
pSprite1~~>renderShader;
rt~~>begin();
pSprite1~~>visit;
rt~~>end();

and here is what goes inside the renderShader()

unsigned long filesize;
const char fullPath;
const GLchar
vertexSource;
GLchar fragmentSource;
const char
buffer;
rndColor = (rand() 3) + 1.0f;
totalTime = 0;

fullPath                        =   CCFileUtils::sharedFileUtils()-\>fullPathFromRelativePath("fshader.fsh");
buffer                          =   (char \*)CCFileUtils::sharedFileUtils()-\>getFileData(fullPath, "r", &filesize);
fragmentSource                  =   (GLchar \*)malloc(sizeof(GLchar) \* (filesize+2));
strcpy((char \*)fragmentSource, buffer);
fragmentSource[filesize]        =   '\\0';

glprog                          =   new CCGLProgram();
glprog-\>initWithVertexShaderByteArray(ccPositionTextureA8Color\_vert, fragmentSource);
this-\>setShaderProgram(glprog);

glprog-\>addAttribute(kCCAttributeNamePosition, kCCVertexAttrib\_Position);
glprog-\>addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib\_TexCoords);
glprog-\>link();
glprog-\>updateUniforms();

colorRampUniformLocation = glGetUniformLocation(glprog-\>getProgram(), "u\_colorRampTexture");
glUniform1i(colorRampUniformLocation, 1);

colorRampTexture = CCTextureCache::sharedTextureCache()-\>addImage("splat.png");
colorRampTexture-\>setAliasTexParameters();

GLfloat params[3];
params[0] = rndColor;
params[1] = (rand()  10) / 15.0f;

params[2] = params[1] + (rand() % 10) / 10.0f + 0.1f;
if (params[2] > 1.0) {
params[2] = 1.0;
}

colorRampUniformLocation = glGetUniformLocation(glprog~~>getProgram, “params”);
glUniform1fv;
glprog~~>use();

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, colorRampTexture->getName());
glActiveTexture(GL_TEXTURE0);

The CCRenderTexture is rendered with a Star shaped sprite in init() as shown below

and after renderTexture() is called, its turns like this

My expectation is the red shader should come only over the star shaped area. But it get distorted at the top.

PS: I am completely new to OpenGL coding, I am not completely sure if the the code in renderTexture() is completely right and OpenGL calls are in order. Please point out if there is any trivial mistake.

Also I suspect the line where SampleSprite is created. Will passing a copy of texture rather than original texture would help? But then how to take a deep copy of CCTexture2D?

SampleSprite* pSprite1 = SampleSprite::createWithTexture(rt->getSprite()->getTexture());

I will post the Shader code, in case if its needed.

Thanks…