Skip to content

Commit

Permalink
Fix rare divide by zero, fix client seg faults
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaivel committed Jun 9, 2024
1 parent c7d6fbd commit e3cb91e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/client/glimpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
case GL_MAX_VIEWPORT_DIMS: \
case GL_POINT_SIZE_RANGE: \
case GL_POLYGON_MODE: \
case GL_ALIASED_POINT_SIZE_RANGE: \
memcpy(data, pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V), sizeof(type) * 2); \
break; \
default: \
Expand Down Expand Up @@ -7134,7 +7135,9 @@ void glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLui
GLsizei len;
memcpy(&len, pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V), sizeof(GLsizei));
memcpy(shaders, (void*)((size_t)pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V) + sizeof(GLsizei)), len * sizeof(GLuint));
*count = len;

if (count)
*count = len;
}

void glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog)
Expand All @@ -7148,7 +7151,7 @@ void glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLcha
memcpy(&len, pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V), sizeof(GLsizei));
memcpy(infoLog, (void*)((size_t)pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V) + sizeof(GLsizei)), len);

if (length != NULL)
if (length)
*length = len;
}

Expand All @@ -7163,7 +7166,7 @@ void glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar*
memcpy(&len, pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V), sizeof(GLsizei));
memcpy(infoLog, (void*)((size_t)pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V) + sizeof(GLsizei)), len);

if (length != NULL)
if (length)
*length = len;
}

Expand All @@ -7177,7 +7180,9 @@ void glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar*
GLsizei len;
memcpy(&len, pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V), sizeof(GLsizei));
memcpy(source, (void*)((size_t)pb_ptr(SGL_OFFSET_REGISTER_RETVAL_V) + sizeof(GLsizei)), len);
*length = len;

if (length)
*length = len;
}

void glGetUniformfv(GLuint program, GLint location, GLfloat* params)
Expand Down
2 changes: 1 addition & 1 deletion src/server/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void overlay_stage1(struct overlay_context *ctx)
return;

ctx->delta_ticks = clock() - ctx->current_ticks;
if (ctx->current_ticks)
if (ctx->current_ticks && ctx->delta_ticks != 0)
ctx->fps = CLOCKS_PER_SEC / ctx->delta_ticks;
}

Expand Down

0 comments on commit e3cb91e

Please sign in to comment.