Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 628644
Collapse All | Expand All

(-)a/coders/svg.c (-8 / +37 lines)
Lines 267-277 Link Here
267
  char
267
  char
268
    **tokens;
268
    **tokens;
269
269
270
  register const char
270
  const char
271
    *p,
271
    *p,
272
    *q;
272
    *q;
273
273
274
  register size_t
274
  size_t
275
    alloc_tokens,
275
    i;
276
    i;
276
277
277
  SVGInfo
278
  SVGInfo
Lines 279-299 Link Here
279
280
280
  svg_info=(SVGInfo *) context;
281
  svg_info=(SVGInfo *) context;
281
  *number_tokens=0;
282
  *number_tokens=0;
283
  alloc_tokens=0;
282
  if (text == (const char *) NULL)
284
  if (text == (const char *) NULL)
283
    return((char **) NULL);
285
    return((char **) NULL);
284
  /*
286
  /*
285
    Determine the number of arguments.
287
    Determine the number of arguments.
288
289
    style="fill: red; stroke: blue; stroke-width: 3"
286
  */
290
  */
287
  for (p=text; *p != '\0'; p++)
291
  for (p=text; *p != '\0'; p++)
288
    if (*p == ':')
292
    if (*p == ':')
289
      (*number_tokens)+=2;
293
      alloc_tokens+=2;
290
  tokens=MagickAllocateMemory(char **,(*number_tokens+2)*sizeof(*tokens));
294
  if (alloc_tokens == 0)
295
    return((char **) NULL);
296
  tokens=MagickAllocateMemory(char **,(alloc_tokens+2)*sizeof(*tokens));
291
  if (tokens == (char **) NULL)
297
  if (tokens == (char **) NULL)
292
    {
298
    {
293
      ThrowException3(svg_info->exception,ResourceLimitError,
299
      ThrowException3(svg_info->exception,ResourceLimitError,
294
                      MemoryAllocationFailed,UnableToConvertStringToTokens);
300
                      MemoryAllocationFailed,UnableToConvertStringToTokens);
295
      return((char **) NULL);
301
      return((char **) NULL);
296
    }
302
    }
303
  (void) memset(tokens,0,(alloc_tokens+2)*sizeof(*tokens));
297
  /*
304
  /*
298
    Convert string to an ASCII list.
305
    Convert string to an ASCII list.
299
  */
306
  */
Lines 304-317 Link Here
304
      if ((*q != ':') && (*q != ';') && (*q != '\0'))
311
      if ((*q != ':') && (*q != ';') && (*q != '\0'))
305
        continue;
312
        continue;
306
      tokens[i]=AllocateString(p);
313
      tokens[i]=AllocateString(p);
314
      if (tokens[i] == NULL)
315
        {
316
          ThrowException3(svg_info->exception,ResourceLimitError,
317
                          MemoryAllocationFailed,UnableToConvertStringToTokens);
318
          break;
319
        }
307
      (void) strlcpy(tokens[i],p,q-p+1);
320
      (void) strlcpy(tokens[i],p,q-p+1);
308
      Strip(tokens[i++]);
321
      Strip(tokens[i]);
322
      i++;
323
      if (i >= alloc_tokens)
324
        break;
309
      p=q+1;
325
      p=q+1;
310
    }
326
    }
311
  tokens[i]=AllocateString(p);
327
  if (i < alloc_tokens)
312
  (void) strlcpy(tokens[i],p,q-p+1);
328
    {
313
  Strip(tokens[i++]);
329
      tokens[i]=AllocateString(p);
330
      if (tokens[i] == NULL)
331
        {
332
          ThrowException3(svg_info->exception,ResourceLimitError,
333
                          MemoryAllocationFailed,UnableToConvertStringToTokens);
334
        }
335
      else
336
        {
337
          (void) strlcpy(tokens[i],p,q-p+1);
338
          Strip(tokens[i]);
339
          i++;
340
        }
341
    }
314
  tokens[i]=(char *) NULL;
342
  tokens[i]=(char *) NULL;
343
  *number_tokens=i;
315
  return(tokens);
344
  return(tokens);
316
}
345
}
317
346

Return to bug 628644