libpurple/plugins/tcl/tcl_ref.c

changeset 16433
2c3aa45bcd7c
parent 16373
4a4d2fdf59f0
child 16477
2fe930b4dcb6
equal deleted inserted replaced
16431:84c4624d91b9 16433:2c3aa45bcd7c
112 { 112 {
113 char *bytes = Tcl_GetStringFromObj(obj, NULL); 113 char *bytes = Tcl_GetStringFromObj(obj, NULL);
114 char *ptr; 114 char *ptr;
115 PurpleStringref *type; 115 PurpleStringref *type;
116 void *value; 116 void *value;
117 int magicnumber = strlen("purple-");
117 118
118 if (strlen(bytes) < 7 119 if (strlen(bytes) < magicnumber
119 || strncmp(bytes, "purple-", 7) 120 || strncmp(bytes, "purple-", magicnumber)
120 || (ptr = strchr(bytes, ':')) == NULL 121 || (ptr = strchr(bytes, ':')) == NULL
121 || (ptr - bytes) == 7) 122 || (ptr - bytes) == magicnumber)
122 goto badobject; 123 goto badobject;
123 124
124 /* Bad Ethan */ 125 /* Bad Ethan */
125 *ptr = '\0'; 126 *ptr = '\0';
126 type = purple_stringref_new(bytes + 7); 127 type = purple_stringref_new(bytes + magicnumber);
127 *ptr = ':'; 128 *ptr = ':';
128 ptr++; 129 ptr++;
129 130
130 if (sscanf(ptr, "%p", &value) == 0) { 131 if (sscanf(ptr, "%p", &value) == 0) {
131 purple_stringref_unref(type); 132 purple_stringref_unref(type);

mercurial