]> git.tdb.fi Git - gldbg.git/blobdiff - source/glprint.c
Protect against giving invalid pointers to writev
[gldbg.git] / source / glprint.c
index e90c0e3d6eb6445ce88de453e88b615b6aba14c4..6f645a7175bf6cd6daa746973267190f55dd7622 100644 (file)
@@ -14,6 +14,8 @@ Distributed under the GPL
 #include "glprint.h"
 #include "tmpalloc.h"
 
+#define UNUSED __attribute__((unused))
+
 typedef struct sGlPrintData
 {
        char *buffer;
@@ -121,6 +123,12 @@ static const char *print_data(const void *data, unsigned size)
 {
        if(!data)
                return "NULL";
+       else if((unsigned long)data<0x100000)
+       {
+               char *buffer = tmpalloc(20);
+               snprintf(buffer, 20, "%p", data);
+               return buffer;
+       }
        else if(!size)
                return "/* data */";
        else
@@ -139,7 +147,7 @@ static void print_gldError(void *user_data, GLenum code)
        snprintf(gpd->buffer, gpd->bufsize, "ERROR: %s", describe_enum(code, "ErrorCode"));
 }
 
-static void print_unhandled(void *user_data, unsigned short func)
+static void print_unhandled(void *user_data, unsigned short func UNUSED)
 {
        GlPrintData *gpd = (GlPrintData *)user_data;
        gpd->buffer[0] = 0;