Bug Summary

File:src/poolvendor.c
Warning:line 68, column 19
Dereference of null pointer (loaded from variable 'vs')

Annotated Source Code

1/*
2 * Copyright (c) 2007, Novell Inc.
3 *
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
6 */
7
8/* we need FNM_CASEFOLD */
9#ifndef _GNU_SOURCE
10#define _GNU_SOURCE
11#endif
12
13#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
16#include <fnmatch.h>
17
18#include "pool.h"
19#include "poolid.h"
20#include "poolvendor.h"
21#include "util.h"
22
23/*
24 * const char *vendorsclasses[] = {
25 * "!openSUSE Build Service*",
26 * "SUSE*",
27 * "openSUSE*",
28 * "SGI*",
29 * "Novell*",
30 * "Silicon Graphics*",
31 * "Jpackage Project*",
32 * "ATI Technologies Inc.*",
33 * "Nvidia*",
34 * 0,
35 * 0,
36 * };
37 */
38
39/* allows for 32 different vendor classes */
40
41Id pool_vendor2mask(Pool *pool, Id vendor)
42{
43 const char *vstr;
44 int i;
45 Id mask, m;
46 const char **v, *vs;
47
48 if (vendor == 0 || !pool->vendorclasses)
1
Assuming 'vendor' is not equal to 0
2
Assuming the condition is false
3
Taking false branch
49 return 0;
50 for (i = 0; i < pool->vendormap.count; i += 2)
4
Assuming the condition is false
5
Loop condition is false. Execution continues on line 53
51 if (pool->vendormap.elements[i] == vendor)
52 return pool->vendormap.elements[i + 1];
53 vstr = pool_id2str(pool, vendor);
54 m = 1;
55 mask = 0;
56 for (v = pool->vendorclasses; ; v++)
6
Loop condition is true. Entering loop body
57 {
58 vs = *v;
7
Value assigned to 'vs'
59 if (vs == 0) /* end of block? */
8
Assuming 'vs' is equal to null
9
Taking true branch
60 {
61 v++;
62 if (*v == 0)
10
Assuming the condition is false
11
Taking false branch
63 break;
64 if (m == (1 << 31))
12
Taking false branch
65 break; /* sorry, out of bits */
66 m <<= 1; /* next vendor equivalence class */
67 }
68 if (fnmatch(*vs == '!' ? vs + 1 : vs, vstr, FNM_CASEFOLD(1 << 4)) == 0)
13
Dereference of null pointer (loaded from variable 'vs')
69 {
70 if (*vs != '!')
71 mask |= m;
72 while (v[1]) /* forward to next block */
73 v++;
74 }
75 }
76 queue_push(&pool->vendormap, vendor);
77 queue_push(&pool->vendormap, mask);
78 return mask;
79}
80
81void
82pool_setvendorclasses(Pool *pool, const char **vendorclasses)
83{
84 int i;
85 const char **v;
86
87 if (pool->vendorclasses)
88 {
89 for (v = pool->vendorclasses; v[0] || v[1]; v++)
90 solv_free((void *)*v);
91 pool->vendorclasses = solv_free((void *)pool->vendorclasses);
92 }
93 if (!vendorclasses || !vendorclasses[0])
94 return;
95 for (v = vendorclasses; v[0] || v[1]; v++)
96 ;
97 pool->vendorclasses = solv_calloc(v - vendorclasses + 2, sizeof(const char *));
98 for (v = vendorclasses, i = 0; v[0] || v[1]; v++, i++)
99 pool->vendorclasses[i] = *v ? solv_strdup(*v) : 0;
100 pool->vendorclasses[i++] = 0;
101 pool->vendorclasses[i] = 0;
102 queue_empty(&pool->vendormap);
103}
104
105void
106pool_addvendorclass(Pool *pool, const char **vendorclass)
107{
108 int i, j;
109
110 if (!vendorclass || !vendorclass[0])
111 return;
112 for (j = 1; vendorclass[j]; j++)
113 ;
114 i = 0;
115 if (pool->vendorclasses)
116 {
117 for (i = 0; pool->vendorclasses[i] || pool->vendorclasses[i + 1]; i++)
118 ;
119 if (i)
120 i++;
121 }
122 pool->vendorclasses = solv_realloc2((void *)pool->vendorclasses, i + j + 2, sizeof(const char *));
123 for (j = 0; vendorclass[j]; j++)
124 pool->vendorclasses[i++] = solv_strdup(vendorclass[j]);
125 pool->vendorclasses[i++] = 0;
126 pool->vendorclasses[i] = 0;
127 queue_empty(&pool->vendormap);
128}