opengles emulator: fix GLESv2 shader source packing

fix segfault when calling glShaderSouce with
empty shader string, length=NULL and count>0

Change-Id: I4c9738d7726fbce22d1e84420faa2bfd772943c5
This commit is contained in:
Liran
2011-07-26 14:11:22 +03:00
committed by David 'Digit' Turner
parent 9e883e8b5f
commit 0a190be2bc

View File

@@ -373,13 +373,15 @@ void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei coun
char *p = ptr; char *p = ptr;
*p = '\0'; *p = '\0';
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int l; int l=0;
if (length == NULL || length[i] < 0) { if (strings[i]!=NULL) {
l = strlen(strings[i]); if (length == NULL || length[i] < 0) {
strcat(p, strings[i]); l = strlen(strings[i]);
} else { strcat(p, strings[i]);
l = length[i]; } else {
strncat(p, strings[i], l); l = length[i];
strncat(p, strings[i], l);
}
} }
p += l; p += l;
} }
@@ -392,7 +394,7 @@ int glUtilsCalcShaderSourceLen( char **strings, GLint *length, GLsizei count)
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int l; int l;
if (length == NULL || length[i] < 0) { if (length == NULL || length[i] < 0) {
l = strlen(strings[i]); l = strings[i]!=NULL ? strlen(strings[i]) : 0;
} else { } else {
l = length[i]; l = length[i];
} }